PDA

View Full Version : Using the Rotate Modeler Command in Python (What are the axis keywords?)



ikarth
03-09-2013, 01:23 PM
I'm trying to take a selection of points and create an object for every point selected, somewhat like the bubbles example script. But the problem I'm running into is that I have no idea how to rotate the objects. The documentation I've been able to find (http://www.lawson3d.com/lwpywiki/index.php?title=Modeler_Commands) says that the ROTATE command takes (nangle kaxis [vcenter]). The angle and the center are easy enough, but I can't figure out what Lightwave is expecting for the axis. It's apparently supposed to be a keyword, but I haven't been able to figure out what that keyword is, and I'm new enough to Python that I'm not sure if there's any way to dig that information out of the SDK, though I have tried.



for position in positions:
percent = random.random()
radius = lwsdk.Vector(self._minStrokeSize + ((self._maxStrokeSize - self._minStrokeSize) * percent))

cs_options = lwsdk.marshall_dynavalues((radius, 5, 5, position))
result, dynavalue = mod_command.execute(mod_command.data, cs_dict["MAKEBALL"], cs_options, lwsdk.OPSEL_USER)

cs_options = lwsdk.marshall_dynavalues((35.0, X, position))
result, dynavalue = mod_command.execute(mod_command.data, cs_dict["ROTATE"], cs_options, lwsdk.OPSEL_USER)

ikarth
03-09-2013, 01:59 PM
Found the answer, through careful interpretation of the docs for the C plugins. The CommandSequence docs have the keywords in quotes, so the X axis is csRotate( xrot, "X", NULL );

Translating that to python gives

cs_options = lwsdk.marshall_dynavalues((35.0, "X", position))
result, dynavalue = mod_command.execute(mod_command.data, cs_dict["ROTATE"], cs_options, lwsdk.OPSEL_USER)
Which works. It also rotates the entire object instead of the just created object, but I kind of expected that. My guess is that I have to play with the selection op codes to alter that behavior. Maybe change OPSEL_USER to OPSEL_DIRECT?