v6.01
Sets or returns Variant data inside the Plugin object. Softimage does not care about the content
or meaning of the data. You can store a wide variety of data, including simple types, Arrays
and object references. Once added the data remains active as long as Softimage is running or until you manually
unload the plug-in. The user data is not persisted.
Note: Plugin.UserData is commonly used for storing a value that can be accessed locally in the plug-in module or
globally by other plug-ins. For scripted plug-ins, it is strongly recommended to use Plugin.UserData as instead
of using global variables defined in the plug-in module. This is particularly important in the context of
rendering operations where plug-ins get executed in multiple threads. When a plug-in gets executed in a different
thread, Softimage makes a copy of its running scripting engine and parses the plug-in file again which re-initializes
any plug-in global variables that are referred to in the plug-in implementation. Plugin.UserData on the other
hand ensures the data integrity across threads.
// get accessor Object rtn = Plugin.UserData; // set accessor Plugin.UserData = Object; |
# How to access a plug-in user data from win32com.client.dynamic import Dispatch # Optional global variable to speed up data access g_userdata = None def GetUserData(): if ( g_userdata == None ): # Dictionary not defined yet # Get the plug-in object storing the dictionary myPlugin = Application.Plugins("My plugin"); if ( myPlugin.UserData == None ): # Dictionary not defined yet, create it and add some object dict = Dispatch( "Scripting.Dictionary" ) dict[ 'SurfPos' ] = XSIMath.CreateVector3() dict[ 'OutPos' ] = XSIMath.CreateVector3() # Store the new dictionary in the plug-in myPlugin.UserData = dict # Cache the dictionary in this module for fast access g_userdata = myPlugin.UserData return g_userdata |