Scripted operator presets provide a mechanism for storing your own private data in the UserData property of the UpdateContext class.
Inside a scripted operator, you can access this property using In_UpdateContext.UserData. This data is cached separately for each instance of a preset operator, so the Update method can modify UserData based on the input connections and variable values without affecting any other instance of the same operator. The UserData property is a variant and can be used to store any data type, including arrays and collections.
In conjunction with the UserData property, there are two methods:
The Init method runs only when the operator is applied or reapplied, as well as when the scene is opened. You would typically use it to set the UserData property to an initial value.
The Term method runs when the scene is closed, that is, when you open another scene or close Softimage. You can use it to perform anything you want done at the end, for example, saving UserData to file.
You do not need to destroy any objects you instantiated in the Init method: Softimage takes care of that automatically.
For example, you can use the Init method to instantiate an ActiveX object like a spreadsheet and store it in In_UpdateContext.UserData. The Update method can then use and modify this data. You can then use the Term method to save the modified spreadsheet. This lets you create your own simulations and store the results.
Creating Init and Term Procedures
You can write the Init and Term functions directly in the bottom pane of the scripted operator editor. These functions should have a single argument which Softimage uses to pass a pointer to an UpdateContext object.
Refer to the UpdateContext [SDK Guide] for information about the properties and methods supported by UpdateContext.
Here is an example of stub Init and Term procedures in VBScript:
Sub Init (InUC) LogMessage "Initializing scripted operator..." End Sub Sub Term (InUC) LogMessage "Terminating scripted operator..." End Sub