|
I’ve built up custom UIs and tools in XSI for several years now, and just recently started moving exclusively towards Python code in XSI.
Today, I hit the wall with trying to customize layouts for property pages via Python. If anyone can spot my error(s), I’d be most grateful!
THE SETUP:
From a basic PPG generated from the [B][I]Animate--> Create--> Parameter--> Custom Property Wizard[/I][/B] we get a simple property page with two parameters attached to it. The crucial code with regards to the layout elements can be found below.
def PythonPPG_test_DefineLayout( in_ctxt ):
oLayout = in_ctxt.Source
oLayout.Clear()
oLayout.AddItem("fileBrowser")
oLayout.AddItem("RadioButtons")
return true
[INDENT] [/INDENT]
Now, I want to customize these basic elements to use different UI types. From my VBScript experience, I would assume to do it in the following manner via Python:
def PythonPPG_custom_DefineLayout( in_ctxt ):
oLayout = in_ctxt.Source
oLayout.Clear()
oLayout.AddItem("fileBrowser","file",siControlFilePath)
oItem = oLayout.AddEnumControl("RadioButtons",["button 1",0,"button 2",1],"",siControlRadio)
oItem.SetAttribute(siUINoLabel,true)
return true
This, however, doesn’t seem to work in Python. Any time I make a call to any [B]siPPGItemAttribute[/B] or [B]siPPGControlType[/B] (in this case, “siControlFilePath”, “siControlRadio” or even a basic “siUINoLabel"), I receive the following error:
# NameError: global name ‘siControlFilePath’ is not defined
Am I doing something wrong in the syntax of these commands? Are the [B]siPPGItemAttribute[/B] and [B]siPPGControlType[/B] libraries unsupported from Python? Perhaps there’s an additional module I’m supposed to import at the beginning of the script?
REPLICATING MY PROBLEM:
Enclosed are two plugin files you can drop in your [B]C:\Users\[username]\Softimage\XSI_7.0\Application\Plugins[/B] directory. [B]PythonPPG_simple.py [/B]is the first one, with nothing done to the PPG elements, and [B]PythonPPG_custom.py[/B] is the one where I’ve attempted to define the types of UI I want for these parameters.
You can pull up these property pages within XSI by running the following code in your Script Editor:
Application.AddProp( 'PythonPPG_simple', Application.ActiveSceneRoot, None, None ) Application.AddProp( 'PythonPPG_custom', Application.ActiveSceneRoot, None, None )
I’m terribly confused-- if anyone can shed some light on this for me, I would appreciate it!
|