UPDATE: Please see the comment from Patrick for a tip. Thanks!
You can use Plugin.UserData to pass data into a plugin.
For example, from outside the plugin, you can store a list in the UserData:
p = Application.Plugins("MyTestPropertyPlugin") p.UserData = ['a', 'b', 'mpilgrim', 'z', 'example']
In the plugin callbacks, you would access the UserData like this:
def MyTestProperty_Test_OnClicked( ): p = Application.Plugins("MyTestPropertyPlugin") if p.UserData == None: Application.LogMessage( "UserData is empty" ) else: Application.LogMessage( p.UserData ) Application.LogMessage( p.UserData[2] )
This will work with lists, but not with dictionaries.
Softimage cannot convert Python dictionaries into a COM Variant type. If you try to store a dict in User Data:
x = Application.Plugins("MyTestPropertyPlugin") x.UserData = {"author":"blairs", "name":"testplugin"}
You’ll get this error:
# TypeError: Objects of type 'dict' can not be converted to a COM VARIANT
I’m afraid there’s no way around that error for Python dictionaries.
This also prevents you from saving dictionaries with SetGlobal or SetGlobalObject.