There are several ways to run scripts in Softimage:
You can run scripts in the script editor. See Running Scripts in the Script Editor.
You can create a custom command to run a script from a button on a custom toolbar.
You can run a custom command automatically whenever the frame or selection changes. See Running Commands Automatically.
You can run scripts in the synoptic view or net view. For more information about running scripts in the synoptic view or net view, refer to the Softimage User's Guide.
You can bind scripts and commands to events so that they are triggered automatically in response to specific actions and states. For more information, see Custom Events.
You can turn off command logging in the history pane while your scripts are running to speed up the execution of your scripts.
Running a script in the script editor is particularly useful while you are testing and debugging your script before creating a custom command.
When run in the script editor, only the global code (script fragments that appear outside of a discrete function or subroutine) is executed. The procedures are still executed if they are called from the global code.
If you select one or more lines before running a script in the script editor, only these lines are executed. If nothing is selected, the entire content in the editing pane is executed.
To run a script in the script editor:
You can choose to run only a part of a script. This lets you concentrate on a particular part of your script. There are two ways of doing this:
Comment out the lines that you do not want to run. For example, to do this in VBScript, add an apostrophe (') at the beginning of a line. When you want to run the line again, remove the apostrophe.
To run a contiguous block of lines, select them in the editing pane before running the script. Make sure to select complete lines.
Usually commands that create objects like CreatePrim and CreateLayer trigger automatic inspection of the new object's property editor. When you run these commands, the property editor for the newly created object opens. When you run scripts that use these commands in the script editor, automatic inspection is always disabled.
However, if these commands are used in scripts that are run outside of the script editor (for example, a self-installing plug-in invoked from a menu item or button), automatic inspection is only disabled in these cases:
If you set the AutoInspect preference to false for the current session (Softimage always resets it back to true each time it is launched).
The self-installing plug-in explicitly sets AutoInspect preference to false for the duration of the plug-in. You can do this either with the SetUserPref command or the Preferences object:
// Using SetUserPref command SetUserPref(siAutoInspect, false); SetUserPref("AutoInspectEnabled", false); // Using Preferences object var oPrefs = Application.Preferences; var oAutoInspect = oPrefs.SetPreferenceValue("Interaction.autoinspect", false);
Disabling automatic inspection is recommended because it improves the performance of your plug-in.
You can run custom commands or native Softimage commands automatically in the following ways:
You can also bind scripts and commands to events so that they are triggered automatically in response to specific actions and states. For more information, see Custom Events.
To run a script, you must first create a custom command. For more information about custom commands, see Custom Commands.
To run scripts automatically when an object is selected in a geometry view:
Type the command name and any parameters in the Selection Change Command box. For example, in VBScript syntax:
LogMessage GetValue("SelectionList")
This setting is stored with your user preferences and is used in all scenes.
To run scripts automatically when the current frame changes
You can select a script or native Softimage command to run automatically after the current frame is changed and the scene is updated. This lets you use scripts to simulate persistent effects.
You can disable command logging temporarily while your scripts are running. This speeds up the execution of scripts because each command is not logged in the script editor's history pane.
Alternatively, you can disable command logging permanently from the Preferences dialog box. See Disabling and Enabling Command and Message Logging.
To disable command logging temporarily:
The following snippet shows how to get the current preference for command logging, turn logging off, and then restore the preference after running the script.
// Get current state var prefs = Application.Preferences; var originalsetting = prefs.GetPreferenceValue("scripting.cmdlog"); // Disable command logging if (!originalsetting) { prefs.SetPreferenceValue("scripting.cmdlog", false); } // // Perform actions // // Restore logging setting prefs.SetPreferenceValue("scripting.cmdlog", originalsetting);
Disable message logging temporarily using scripting.msglog in place of scripting.cmdlog.
Disable the automatic opening of property editors using Interaction.autoinspect. See Property Editor Automatic Inspection.
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License