SetGlobal and its companion command GetGlobal provide a simple means to store and retrieve values which act like "global variables". Each variable is indentified by a unique string. To change the value of a previously set variable call this command with a new value. To erase a global variable call this command with null as the value.

These variables are accessible from any script and remain active during the duration of the Softimage session.

Warning: For persistent Global values it is better to use a CustomProperty or a Custom Preferences object.

Tip 1: It is possible to store a Softimage object inside a global variable. However when storing a reference to a Softimage object, it is often safer to store the fullname string of the object rather than the object itself. This ensures that even if the scene is closed, reopened or significantly changed you can get a valid reference to the object (as long as the object isn't renamed). This is demonstrated in the examples below.

Tip 2: This command will convert any JScript Array or user-created script object into a SAFEARRAY (see Array). To maintain the data in its original form use SetGlobalObject.

Tip 3: It is unnecessary to use this functionality if the entire plug-in is implemented inside a single script, because any variable within the global scope is accessible inside all functions. (The only exception is PPGLayout logic callbacks, which cannot read the values of global variables set by non-PPGLayout callbacks.)

Tip 4: Global variables can be very useful, but usage should be kept to a minimum to avoid unexpected side-effects, "spagetti" code and code that is difficult to read, debug and maintain. Each global variable name should be well chosen to avoid potential conflict with other scripts. For example if two plug-ins both try to use a global variable named "x" then both will be prone to random or unexpected failure.

Tip 5: This feature is implemented as a self-installed JScript Plugin using the powerful "Scripting.Dictionary" object which is available to both VBScript and JScript. For more details refer to the actual implementation code (GlobalVarPlugin.js).

Scripting Syntax

SetGlobal( in_VariableName, in_Value )







The name of the global variable



A new value for the global variable

See Also






• See SetGlobal.1.js

• See SetGlobal.2.vbs

Autodesk Softimage 2011