Jump to content
Developer Wiki and Function Reference Links √ó

Object Selectors for VP Indirect Lighting and Ambient occlusion

Recommended Posts

Hey Guys...


I don't see Object selectors for a viewport's¬†Indirect Light and Ambient occlusion..¬† on the developer site..¬† but I know.. that doesn't always mean it doesn't exist¬†ūü§≠


Anyone figure out, or know of undocumented selectors or some other means of setting these two?






Link to comment


   I haven't tried these, but give them a whirl. They look promising.


SetObjectVariableBoolean(LYRhand, 150, True/False);   { Layer Ambient On/Off }

SetObjectVariableReal(LYRhand, 151, ###);     { Layer Ambient Brightness - 0-100?; you'll have to figure out the range. }


SetObjectVariableBoolean(VPhand, 1302, True/False);   { Ambient Occlusion On/Off }

SetObjectVariableReal(VPhand, 1303, ###);     { AO Strength - 0.0-1.0? or 0-100?; you'll have to figure out the range. }

SetObjectVariableReal(VPhand, 1304, ###);     { AO Size - you'll have to figure out the values. }





  • Like 1
Link to comment

@Fuge,  REDO...   Now that I have played with it a little, I'm going to revise my previous guess.


With ObjectVariables 1014 and 1015, I can read and write to both Viewport variables:

   VP_Amb := GetObjectVariableBoolean(VPhand, 1014);         { Viewport Ambient }
    VP_Amb_Bright := GetObjectVariableReal(VPhand, 1015);   { Viewport Ambient Brightness }


    SetObjectVariableBoolean(VPhand, 1014, True/False);        { Viewport Ambient On/Off }
    SetObjectVariableReal(VPhand, 1015, 0.37);                         { Viewport Ambient Brightness - 0.0-1.0 }



However, I can read and write to ObjectVariable 1302.

    AO_On := GetObjectVariableBoolean(VPhand, 1302);          { Ambient Occlusion }
    SetObjectVariableBoolean(VPhand, 1302, True/False);       { Ambient Occlusion On/Off }



But, I can only read ObjectVariables 1303, and 1304.

    AOStrength := GetObjectVariableReal(VPhand, 1303);      { Ambient Occlusion Strength - 0-100 }
    AOSize := GetObjectVariableReal(VPhand, 1304);              { Ambient Occlusion Size }



If I change the values for "Ambient Occlusion Strength" and "Ambient Occlusion Size" in the Lighting Options dialog box, I can read my manual changes, but if I try to set the values by script, the settings do not take.


More on the "Indirect Lighting" setting in the next post.





Link to comment


Here's a partial map of the Object Variable numbers for the Viewport Lighting Options dialog.

ObjVars 1014 and 1302-1304 are described above. ObjVar 1269 is clear as mud.


ObjVar 1269 is another object variable that you can read, but cannot set. Or at least I have not found a successful way to set it. If you read it with GetObjectVariableInt(), or GetObjectVariableLong(), you will get the numbers 0-3, or 5 which correspond to the settings shown below. If you try to set the object variable, the values and the menu don't change. I assume the inability to write to variables 1269, 1303, and 1304 is a bug and I'll report it in the morning. If I find out it's WAD, I'll post back so you know, otherwise I'll post back when it gets fixed.




Sorry this didn't turn out better.



Link to comment

Hey Ray  -  @MullinRJ,


Thanks for spending so much time on this, much appreciated.¬† ¬† At least I got 50% of what I was hoping figured out¬†¬†ūüėú¬†


Yeah,  I think you're correct,  If you can GET it.. you should be able to SET it...   Quick summary and test script below...   if helpful to anyone else.. and for later reference..


Have a great day!



Procedure SetSelectedVPLighting;

 KIndirectLightIndex = 3;                  { 0, 5, 1, 2, 3 - For type in order }
 KAmbInfoONOFF = TRUE;               { Boolean True/False }
 KAmbInfoBrightNess = 0.85;           { Number in decimal for percentage }
 KAmbOcclusionONOFF = TRUE;     { Boolean True/False }
 KAmbOcclusionStrength = 0.50;    { Number in decimal for percentage }
 KAmbOcclusionSize = 100;             { Real Number for size }  
  viewportHandle :HANDLE;

    viewportHandle := LSActLayer;   { Last selected object ,  Select a viewport }
    SetObjectVariableLongInt(viewportHandle,1269,KIndirectLightIndex);          { Bug - runs but doesn't set - Indirect Lighting Index, 0, 5, 1, 2, 3 }    
    SetObjectVariableBoolean(viewportHandle,1014,KAmbInfoONOFF);               { Ambient Info On/Off }
    SetObjectVariableReal(viewportHandle,1015,KAmbInfoBrightNess);               { Ambient Info Brightness }
    SetObjectVariableBoolean(viewportHandle,1302,KAmbOcclusionONOFF );    { Ambient Occlusion }    
    { SetObjectVariableReal(viewportHandle,1303,KAmbOcclusionStrength);      { Broken - fails - Ambient Occlusion Strength % }
    { SetObjectVariableReal(viewportHandle,1304,KAmbOcclusionSize);              { Broken - fails - Ambient Occlusion Size }    

Run (SetSelectedVPLighting);

Link to comment

Here's some additional selectors:

ovRenderStyleQualityGeometry		= 1261; //Short
ovRenderStyleQualityAntiAliasing	= 1262; //Short
ovRenderStyleQualityIndirectLighting = 1263; //Short
ovRenderStyleQualitySoftShadows		= 1264; //Short
ovRenderStyleQualityBlurriness		= 1265; //Short
ovRenderStyleQualityEnvLighting		= 1266; //Short
ovRenderStyleMaxReflections			= 1267; //Short
ovRenderStyleApplyLighting			= 1268; //Boolean
ovRenderStyleIndirectLighting		= 1269; //Long
ovRenderStyleHDRIRefNumber			= 1270; //Long
ovRenderStyleHDRIOption				= 1271; //Long
ovRenderStyleHasHDRIOption			= 1272; //Boolean
ovRenderStyleEnableAmbient			= 1273; //Boolean
ovRenderStyleAmbientBrightness		= 1274; //Real
ovRenderStyleAmbientColorR			= 1275; //Real
ovRenderStyleAmbientColorG			= 1276; //Real
ovRenderStyleAmbientColorB			= 1277; //Real
ovRenderStyleEmitterBrightness		= 1278; //Long
ovRenderStyleWhiteColorTemp			= 1279; //Long
ovRenderStyleApplyBackground		= 1280; //Boolean


There seems to be two selectors, one that's ovRenderStyleQualityIndirectLighting and one called ovRenderStyleIndirectLighting. You can see if the former will work to set the option. You may also have to set ovRenderStyleApplyLighting to true, or instead/additionally use ovRenderStyleMaxReflections to set the number of reflections.

Link to comment

Well after going down the rabbit¬†ūüźá hole on this one¬†..¬† I can't say I've made much progress on it.¬† ¬†Some of the additional Selectors work,¬† for example 1278 for¬†ovRenderStyleEmitterBrightness, however nothing works for setting Indirect Lighting with any combination of selectors as Josh suggested.¬†¬†


I then thought...¬† Hmm what if I set a Render Style for the Background Render that best matches Shaded since it would have it's¬†Lighting preset under Lighting Options for the Viewport.¬† ¬†If you do a GET for it,¬† when a Render Style is chosen it returns 15,¬† ¬†however if you do a SET with 15, it sets it to Custom Renderworks instead ūüėÜ.¬† Of course there doesn't seem to be a way to select which Render style you'd want anyhow, from what I can discern.¬† I'd only have one in this particular template file.¬† So for the time being it appears to be a no go.¬†


Hopefully in the future there will be a bit more clarity and object sectors for this.   In my case..  it would really be helpful for automating assembly instructions.

Link to comment
  • Vectorworks, Inc Employee

i noticed some of the SetObjectVariable calls take a RenderStyleHandle instead of a ViewportHandle. Try this:
viewportHandle := LSActLayer;  { Last selected object , Select a viewport }
renderStyleHandle := GetObjectVariableHandle(viewportHandle, 1281); { ovRenderStyle=1281 }

SetObjectVariableBoolean(renderStyleHandle,1302,KAmbOcclusionONOFF );


  • Like 2
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...