You can run scripts in batch mode from a shell or command prompt window, without invoking the interface. This is also known as command line scripting. You can specify the procedure to run, as well as supply any necessary arguments. Before running a script in batch mode, you may need to first prepare it.
![]()
|
In batch mode, the command history is logged to the standard output stdout. If desired, you can also log it to file as described in The Command Log |
On Windows, you can run either xsi or xsibatch in batch mode. They support identical options. The difference is that xsibatch has been compiled to better support remote execution on another machine via rsh or Telnet — see Running Batch Scripts Remotely. Of course, xsibatch can also be run locally. In addition, xsibatch does not open a second command window that needs to be closed — see Automatically Closing the Command Window.
On Linux, a separate xsibatch executable is not needed because of the way that operating system works. Just use xsi on the command line.
Preparing Scripts for Batch Mode
In batch mode, scripts cannot require any interactive input such as prompting for a file or path — this does not include property editors that open automatically as you work in the interface. For example, the following code would generate an error if it is run in batch mode. This is because the OpenScene command, when invoked without any arguments, displays a dialog box that prompts for a scene to import.
sub MyBatchScript() OpenScene ' error end sub ' Main MyBatchScript |
There are two ways to deal with this. The first way is to explicitly provide all arguments in the script. For example:
OpenScene "C:\MyProject\MyScene.scn", false |
In this case, the false argument is a flag that indicates that there should be no prompt to save changes to the current scene. There is a similar flag for DeleteAll.
The other way is to declare any necessary parameters as arguments in a procedure declaration and then pass them on the command line when the script is run in batch mode. For example, in VBScript you would declare the arguments for a procedure as follows:
Sub myproc(myargname1, myargname2) ... End Sub |
At a command prompt, you would then run the script as shown below (it should all be on one line):
xsi -script myscriptfile.vbs -main myproc -args -myargname1 myargvalue1 -myargname2 myargvalue2 |
How to check in which mode (batch or interactive) Softimage is running
You can use the Interactive property on the Application object to find out whether Softimage is running in interactive mode (returns True) or in batch mode (returns False):
' Using Application.Interactive is the same as Application.Interactive = True If Application.Interactive Then Application.LogMessage "The application is running in interactive mode." Else Application.LogMessage "The application is running in batch mode." End If
To run a script in batch mode, you must set the environment and then start Softimage with the script.
Before running a script in batch mode, you should first set the environment properly:
• On Windows, open a command prompt.
To do this, choose All Programs > Softimage Products > Autodesk Softimage 7.5 > Command Prompt from the Windows Start menu.
• On Linux, open a shell and source the .xsi_7.5 Softimage resource file.
Launching Softimage with a Script
To run the program and a script in batch mode, start Softimage with the
If you need the script to run in the Softimage user interface, for example, to perform hardware rendering, use -uiscript instead of -script.
To run simple scripts in batch mode
To run a simple VBScript file named myscript.vbs, use the following syntax at the command prompt:
xsi -script myscript.vbs |
If there is a space in the path or file name, enclose the complete path in double quotes, for example:
xsi -script "\My Files\myscript.vbs" |
To specify the scripting language in batch mode
The scripting language is determined by the file name extension according to information in the registry: by default, this is .vbs for VBScript, .js for JScript, .pls for PerlScript, and .pys for Python.
If your script file uses a different extension, you can specify the language explicitly with the
xsi -script myscript.xxx -lang VBScript xsi -script myscript.xxx -lang JScript xsi -script myscript.xxx -lang PerlScript xsi -script myscript.xxx -lang Python |
To specify a procedure in batch mode
By default, when you run a script in batch mode, only global code is executed. If your script contains procedures, you can use the
xsi -script myscript.vbs -main myproc |
![]()
|
Even when a procedure is specified, global code may be executed before the procedure is called. This is a side effect of parsing the script with some scripting engines. To be certain that your script behaves predictably in all situations, do not mix global code and procedures. |
To supply arguments in batch mode
If your procedure requires arguments, you can specify them after the
xsi -script myscript.vbs -main myproc -args -myargname1 myargvalue1 -myargname2 myargvalue2 |
![]()
|
• If you specify arguments with the • Softimage cannot pass arguments in batch mode to scripts written in Perl. For this languages, you can write a second script that calls the appropriate procedure using the desired argument values. |
Running Batch Scripts Remotely
You can run Softimage in batch mode remotely using Telnet or a remote shell (rsh):
• On Linux, use xsi -script as usual.
• On Windows, use xsibatch -script instead.
The xsibatch command supports the same command-line options as xsi. However, the beta version of the Telnet daemon included in some versions of the Windows Resource Kit (TELNETD) is not supported. You can also run xsibatch locally if desired.
The same thing applies to using the -render and -export options remotely.
Automatically Closing the Command Window
By default in batch mode on Windows, Softimage runs in a new window that stays open after the process is finished. This allows you to see any messages that have been logged to the console.
However, it is sometimes desirable to turn this behavior off. For example, you may want to automatically run several scripts one after another from a single batch file. If the new window does not close, control does not return to the original batch process and the next script cannot start.
To make the command window close automatically, do either of the following:
• Use xsibatch as described in Running Batch Scripts Remotely.
or
• Use xsi with the -continue option in the command line that starts Softimage:
xsi -continue -script myscript.vbs |
When started with this option, the new window closes automatically when the process terminates. The script or batch file that started Softimage can then continue processing.
When running scripts, you can set your preferences to allow for real-time message logging. This is particularly useful when rendering in batch mode. To activate real-time message logging:
1. Open the Preferences window by choosing File > Preferences from the main menu.
2. Click Scripting.
3. Set the Real-Time Message Logging option as you want it:
- When this option is off (default), commands that involve picking sessions are properly logged after all the inputs have been picked. This is useful when interactively working in the interface because the commands logged in the script editor can be played back with no modifications.
- When this option is on, messages are logged as they occur. This lets you see, for example, messages about each frame as it is rendered rather than after all frames are rendered.
You can also get and set this preference using the "RealTimeMessageLogging" string and the GetUserPref and SetUserPref commands.
For example, the following VBScript script stores the current preference, then activates real-time message logging, renders the current pass, and finally restores the original preference:
Dim flag
flag = GetUserPref("RealTimeMessageLogging")
SetUserPref "RealTimeMessageLogging", True
RenderPass
SetUserPref "RealTimeMessageLogging", flag
|
Autodesk Softimage v.7.5