Working with Commands

Autodesk Softimage is command-based—anything you can do with a scene interactively in the interface, you can also accomplish with commands. As you work, the corresponding commands are logged to the command history. You can then repeat these commands or use them as the basis for a script.

What Is a Command?

Commands are actions that have an immediate effect. Whenever you do something that changes the scene data—for example, select a scene element, move an element, change a parameter value, or set a key —a command is logged to the command history. When this happens, the corresponding command appears in the Command Box in the bottom-left corner of the Softimage window:

 

In this respect, commands are different from tools. For example, when you activate the Translate tool by clicking the Translate (T) button on the Transform panel, no command is logged to the history — it is only when you actually translate something that a command is logged. Similarly, no command is logged when you switch from Local to Global transformation mode.

Actions that affect only the interface are not logged, either. For example, nothing is logged when you open or close a view, or when you maximize a viewport.

Usually, any command that is logged can be undone with the Edit > Undo command available on the main menu. There are some exceptions to this, including the DeleteAll command.

Anatomy of a Command

Softimage logs commands using the syntax of the current scripting language as set in your preferences. For example, select an object, press the v key to activate the Translate tool, then move the object around in View mode. If you are using the default scripting language of VBScript, a line similar to the following is logged:

Translate , 2.996, 1.887, -2.635, siRelative, siView, siObj, siXYZ

The first word is the command name, in this case Translate. After the command name come the arguments, in order and separated by commas. You can get help on the syntax for all the commands and arguments from the script editor—see Script Editor Help and Reference Information.

In the Translate example, notice that the first comma is preceded by a space but no argument: this means that the first argument has been omitted. If an optional argument is omitted, its default value is used. In the case of the Translate command, the first argument specifies which object to translate and the default value is the current selection. The next three arguments specify the translation values in the X, Y, and Z directions. The remaining arguments specify options like the current transformation mode.

When constructing or deconstructing an Softimage command, be aware of the following VBScript syntax conventions:

• Commands do not use parentheses for their arguments. The exception is when you want to use a return value; for example, when using GetValue().

• If an optional argument is omitted, the default is used. If you omit an optional argument in the middle of a line, you must use a comma as a placeholder. If you omit one or more optional arguments at the end of a line, you do not need commas.

• Literal strings must always appear inside double quotes.

• There is no special character needed at the end of a command.

• You can include multiple commands on a single line by separating them with colons.

• Any text after a single quote (') is a comment and is ignored by the interpreter.

• You can continue a long line on the next line by adding an underscore character (_) to the end of the first line.

Command Levels

Commands can be divided into high-level and low-level:

High-level commands correspond to the commands that are available in the interface: these are the commands that generally set up some interaction with the user interface (picking scene objects, opening dialog boxes, etc.) and are usually called through menus or buttons. These commands are usually implemented as scripts and get logged as you work.

Low-level commands correspond to what is happening behind the scenes. They generally delegate to a task (like a COM object). Often, a high-level command in the history is actually several low-level commands executed in sequence. Low-level commands are especially useful when you are writing your own scripts from scratch rather than simply repeating commands from the history.

Often, there are high and low-level versions of the same command. Low-level commands usually begin with the prefix SI. For example, the high-level AddProp command adds a custom property set and opens a property editor when it is run as a script from the script editor or a synoptic view (but not when it is embedded inside a custom command). The corresponding low-level command SIAddProp does the same thing but without opening any property editor.

Commands and Immediate Mode

If you want to be able to replay commands from the history, don’t use immediate mode. When you get a primitive or apply an operator in immediate mode, the corresponding property editor opens with OK and Cancel buttons.

If you change a parameter value while the property editor is open, no SetValue command is logged. As a result, you will get different results when you play back commands from the history.

Commands That Arent Really Commands

There are some native Softimage keywords that seem to behave like commands, but you can also think of them as methods of the Application object. These methods include:

• ExecuteScript

• LogMessage

• Version

Because the Application object is automatically implied, you can use these methods as if they were native Softimage commands. For example, instead of using:

Application.LogMessage "Hello, sailor!"

you can also simply use:

LogMessage "Hello, sailor!"

However, there are two consequences of the fact that these are methods rather than scripting commands:

• If you are looking for help on these statements in the HTML reference, they are listed under Methods rather than Commands.

• You cannot terminate a running script at the location immediately before these statements are executed. For more information about terminating scripts, see Terminating Scripts.



Autodesk Softimage v.7.5