PDA

View Full Version : Where do I find information on "itemid_to_str"



clintonman
02-08-2013, 10:29 PM
I use the lwsdk.itemid_to_str(nullItemID) to convert the item id to a string for use in a select command, but I have no idea how I knew to do it. I can't find it in the docs anywhere. The example below is from a parenting script test. Any ideas where to look?


# -*- Mode: Python -*-
# -*- coding: ascii -*-

"""
This is a LightWave Generic plug-in that adds a new Null object
and positions it at <0, 1, 0>. It uses the streamlined "single-shot"
format introduced with LightWave 11.5 for Layout Generic and Modeler
CommandSequence scripts.
"""

try:
import lwsdk
except:
import sys
print "This is a LightWave Python Generic plug-in. Please execute it within LightWave."
sys.exit(1)

ga = lwsdk.GenericAccess()
if ga.valid():
ga.evaluate("AddLight SpotLight mylight")

interface_info = lwsdk.LWInterfaceInfo()
selected_items = interface_info.selected_items()
lightItemID = selected_items[0]

print lwsdk.itemid_to_str(lightItemID)

ga.evaluate("Position 0 0 %f" % 3)

interface_info = lwsdk.LWInterfaceInfo()
if not (interface_info.generalFlags & lwsdk.LWGENF_AUTOKEY):
ga.evaluate("CreateKey %f" % interface_info.curTime)

#add null parent
result = ga.evaluate("AddNull LightNull")
interface_info = lwsdk.LWInterfaceInfo()
selected_items = interface_info.selected_items()
nullItemID = selected_items[0]

print lwsdk.itemid_to_str(nullItemID)

#select the light and parent to the null
ga.evaluate("SelectItem %s" % lwsdk.itemid_to_str(lightItemID))

#parent
# /LightWave11.0/sdk/lwsdk11.0/html/commands/layout.html - UpdateMotion needed for parent in place
ga.evaluate('UpdateMotion')
ga.evaluate("ParentItem %s" % lwsdk.itemid_to_str(nullItemID))

#select null
ga.evaluate("SelectItem %s" % lwsdk.itemid_to_str(nullItemID))

if not (interface_info.generalFlags & lwsdk.LWGENF_AUTOKEY):
ga.evaluate("CreateKey %f" % interface_info.curTime)

xchrisx
02-08-2013, 11:08 PM
Possibly here?
http://forums.newtek.com/showthread.php?127883-Code-Snippets-(aka-quot-How-to-quot-)

its in the 3rd post by Celshader

clintonman
02-09-2013, 11:33 AM
Possibly here?
http://forums.newtek.com/showthread.php?127883-Code-Snippets-(aka-quot-How-to-quot-)

its in the 3rd post by Celshader
Her sample shows how to use it, but not how she knows it. I was hoping to find some official documentation because there could be a lot more useful commands in the same place. Assuming such a place exists.

clintonman
03-01-2013, 10:44 AM
I found some (new to me) information.

import lwsdk
help(lwsdk)
gives a lot of useful information but doesn't have the itemid_to_str

import lwsdk
dir(lwsdk)
lists the itemid_to_str. So I imagine there's a bunch of useful stuff hidden in the list generated by the dir command. It's a long list so you need to save the log to see it all properly.

help(lwsdk.itemid_to_str)
gives more specific information

Celshader
09-01-2013, 02:26 PM
Her sample shows how to use it, but not how she knows it. I was hoping to find some official documentation because there could be a lot more useful commands in the same place. Assuming such a place exists.

My chief source of LWPython documentation has been the example scripts located in LightWave's "support\plugins\scripts\Python" directory. These example scripts use lwsdk.itemid_to_str:



support\plugins\scripts\Python\Layout\Generic\bake _instance.py
support\plugins\scripts\Python\Layout\Generic\scat ter_objects.py
support\plugins\scripts\Python\Layout\Generic\togg le_instance.py
support\plugins\scripts\Python\Layout\Master\ring_ test.py
support\plugins\scripts\Python\Layout\Utility\Tool \split_bone.py