Running Scripts

There are several ways to run scripts in Softimage:

• You can run scripts directly from the script editor as described in Running Scripts from the Script Editor below.

• You can run a script from a button on a custom toolbar as described in Adding Script Buttons.

• You can run a script in batch mode from a command line as described in Batch Scripts.

• You can run scripts from synoptic views as described in Synoptic Views.

• You can run scripts from Net View as described in Intranets for Net View.

You can use a script as the action for a particle event. For more details, see Particles [Particles].

• You can create a custom command to run a script as described in Custom Commands.

• 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 Events.

Running Scripts from the Script Editor

You can run a script directly from the script editor. This is particularly useful while you are testing and debugging your script before creating a custom command.

When run from the script editor, only global code (that is, script fragments that appear outside of a discrete function or subroutine) is executed. Note that procedures are still executed if they are called from global code.

If one or more lines are selected when you run a script from the script editor, only those lines are executed. If nothing is selected, the entire contents of the editing pane are executed.

To run a script from the script editor

Do one of the following:

• Click Run on the command bar.

 

or

• Press F5.

or

• Choose Edit > Run from the command bar.

or

• Right-click in the editing pane and choose Run from the pop-up menu.

Running Scripts from a Button

You can easily create a button in a custom toolbar to run a script.

1. Make sure that a custom toolbar (or a toolbar tab in a shelf) is displayed.

To display an existing custom toolbar, choose it from the View > Toolbars menu on the main menu.

For more information about custom toolbars in general, see Toolbars and Shelves.

2. Select some lines from a script or text editor and drag them onto a blank area of a custom toolbar.

3. When prompted, make sure that Script Button is selected and click OK.

4. Make any desired modifications:

- Script Commands contains the commands that will be replayed when the button is pressed.

- Make sure that Scripting Language is set to the correct value.

- Use the other options to customize the button’s interface.

5. Click OK. The button is created.

You can now click the button to run the script. You can modify the button or the script by right-clicking on the button and choosing Customize Button.

Disabling Command Logging Temporarily

You can disable command logging temporarily while your scripts are running. This speeds up the execution of scripts considerably because each command is not echoed in the script editor’s history pane.

As an alternative to the procedure below, you can also disable command logging permanently in your preferences — see Disabling and Enabling Command and Message Logging.

 

Disabling the logging of commands has no effect on the ability to undo commands individually. It affects only whether commands are echoed to the history pane of the script editor.

To disable command logging temporarily in a script

The following fragments of VBScript code demonstrate how to get the user’s current preference for command logging, turn logging off, and then restore the user’s preference after your script is finished.

   ' get current state
bEnabled = getuserpref( "SCR_CMDLOG_ENABLED")
' disable command logging
if bEnabled then
   setuserpref "SCR_CMDLOG_ENABLED", False
end if

' do your stuff

' restore logging if previously enabled
if bEnabled then
   setuserpref "SCR_CMDLOG_ENABLED", True
end if

 

You can also:

• Disable message logging temporarily using SCR_MSGLOG_ENABLED in place of SCR_CMDLOG_ENABLED.

• Disable the automatic opening of property editors using AutoInspectEnabled. Note that property editors do not open automatically for scripts run directly from the script editor. However, changing this preference can be useful inside a scripted command. Note that if you modify this value in a script, Softimage restores the old value when the script finishes. Softimage also turns this preference on at startup. This prevents users from wondering why property editors don’t open automatically anymore.

Terminating Scripts

To stop execution of a script while it’s running, press Ctrl+Break (Ctrl+Pause on some keyboards). You may need to press this key combination a few times because the keyboard is checked only before each native Softimage command is executed.

 

Ctrl+Break does not work with PerlScript. The scripting engine does not stop on errors.

If your script contains only Softimage object model statements and commands from a scripting language, you cannot stop it.



Autodesk Softimage v.7.5