Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Softimage® / XSI SDK / Problems building custom PPG layouts in Python
  RSS 2.0 ATOM  

Problems building custom PPG layouts in Python
Rate this thread
 
30105
 
Permlink of this thread  
avatar
  • bkeane
  • Posted: 19 September 2008 04:30 PM
  • Total Posts: 8
  • Joined: 29 August 2008 03:16 PM

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_DefineLayoutin_ctxt ):
    
oLayout in_ctxt.Source
    oLayout
.Clear()
    
oLayout.AddItem("fileBrowser")
    
oLayout.AddItem("RadioButtons")
    return 
true

[INDENT]2008-09-19_2130.png[/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_DefineLayoutin_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.ActiveSceneRootNoneNone )
Application.AddProp'PythonPPG_custom'Application.ActiveSceneRootNoneNone )

I’m terribly confused-- if anyone can shed some light on this for me, I would appreciate it!



Attachment Attachment
Replies: 0
avatar

http://softimage.wiki.avid.com/s...nizeXSIConstantsEnums.htm



Replies: 0
avatar
  • bkeane
  • Posted: 19 September 2008 10:10 PM

Fantastic!

Thanks, Stephen!  That was the piece I was missing.

[INDENT]2008-09-20_0315.png[/INDENT]

For anyone else running into this issue, the magic bullet is to call the [B]siPPGItemAttribute[/B] or [B]siPPGControlType[/B] element from the [B]constants[/B] class.

The corrected code reads as follows:

def PythonPPG_custom_DefineLayoutin_ctxt ):
    
oLayout in_ctxt.Source
    oLayout
.Clear()
    
oLayout.AddItem("fileBrowser","file",[B]constants.[/B]siControlFilePath)
    
oItem oLayout.AddEnumControl("RadioButtons",["button 1",0,"button 2",1],"",[B]constants.[/B]siControlRadio)
    
oItem.SetAttribute([B]constants.[/B]siUINoLabel,true)
    return 
true

Thanks again, Stephen!

Great stuff!

: )



Replies: 0