PDA

View Full Version : LWPython Render Lines and Render Instances values



Diepgroen
01-10-2017, 07:15 AM
Sharing a weird behavior I've encountered and how to work around it: I've been exploring Python and the Lightwave SDK. Currently I'm attempting a preset script which reads my favorite render and camera settings from a json file. When i finish it should look like this:

135556

While diving into this project i've also been stuck for a while because of two render option commands which were throwing me off and wheren't doing what they've been told.


- Render Lines "lwsdk.LWSceneInfo().renderOpts & lwsdk.LWROPT_RENDERLINES"
- Render Instances "lwsdk.LWSceneInfo().renderOpts & lwsdk.LWROPT_RENDERINSTANCES"


When I print these out in Python I get the following values

- RenderLines: 262144 ( when toggled on) and 0 (when toggled off)
- Render Instances: 1073741824 ( when toggled on) and 0 (when toggled off)


And these are the values stored in my json file (happens automatically when i save a preset)

135557

Nothing strange there.
Feeding the "lwsdk.LWSceneInfo().renderOpts & lwsdk.LWROPT_RENDERLINES" value back into a command wasn't toggling these on or off.

lwsdk.command("RenderInstances 1073741824")
lwsdk.command("RenderLines 262144")

But the DepthBufferAA at the other hand does react and toggle on or off using it's original values.
lwsdk.command("DepthBufferAA 8192") Value given by "lwsdk.LWSceneInfo().renderOpts & lwsdk.LWROPT_ZBUFFERAA"

So it's just the "Render Lines" and "Render Instances" which needed a different approach to get them working.

SOLUTION:
lwsdk.command("RenderInstances 1")
lwsdk.command("RenderLines 1")

To counter-act this, If my script encountered the "Render Lines" and "Render Instances" in my preset file it also had to substitute the original value e.g. "1073741824" with "1". Only then will these toggles on. Toggling off was not the problem because they do react to the 0.

Maybe not relevant but here a screengrab of the small bit of code

135558