PDA

View Full Version : How do I get the selected objects of a scene?



Celshader
04-05-2012, 07:24 PM
I'm looking for the Python equivalent of the following LScript command:


Scene().getSelect()

The LScript->Python converter suggested:


lwsdk.LWSceneInfo().getSelect()

However, PCore throws an AttributeError over the use of "getSelect()."

Any thoughts?

evenflcw
04-05-2012, 07:43 PM
Don't use lscript as your source, but the c-sdk docs instead if you're lacking documentation on python sdk. It is a much closer match.

csdk:
LWInterfaceInfo* intinfo = global(LWINTERFACEINFO_GLOBAL, GFUSE_TRANSIENT) ;
intinfo->selItems();

python:
lwsdk.LWInterfaceInfo().selected_items()

One way to look at it: SceneInfo contains information about the scene, and will not contain more than what might be saved to LWS. Selections are transient and only needed when the scene is manipulated, thus is a property of the environment which edit the scene - so it belongs in InterfaceInfo. Or just look through the csdk docs. As a veteran LW user you can likely make sense of most members in each class and figure out how the class model is designed.

clintonman
04-05-2012, 08:19 PM
Also look at the sample scripts
....\LightWave11.0\support\plugins\scripts\Python\ Layout\Generic

The "scatter_objects.py" script uses selection

Celshader
04-05-2012, 09:13 PM
Thanks, guys. :) I was looking in the LightWave SDK, but I was not able to find this information. I also looked at some of the Python scripts, but I had not looked at the "scatter_objects.py" script. So this helps me a lot.