Your Ad Here

Scripting Languages

Simple scripts involve the sequential repetition of XSI commands. More advanced scripts, however, require the use of variables, conditional statements, loops, functions, and subroutines. For these elements, you can use existing scripting languages as the glue that holds the native XSI commands together. If you already know a supported scripting language, you do not need to learn a new one to create advanced scripts in XSI.

Using a scripting language, you can create arguments for your scripts and interact with other applications. You can also use third-party tools to test and debug your scripts.

You can use the commands, functions, operators, and statements of a scripting language to create complex scripts. In this way, scripts can be more than a simple, sequential repetition of XSI commands.

All scripting languages include certain basic features, although the specific implementations are different. These basic features include:

• Statements that control the flow of execution, including conditionals (If… Then… Else… or Select Case) and loops (For… Next or While… Wend).

• Functions that convert between basic data types, such as numbers and strings. Many languages convert data types automatically, based on the context.

• The ability to define procedures and functions.

• The ability to provide simple interaction with users, including message and input boxes.

Note that if you want to pass data to scripts in batch mode, you should use arguments instead of input boxes—see Preparing Scripts for Batch Mode.

• The ability to declare and use variables and constants.

Note that variables are not global to the scene and cannot be shared between scripts. However, you can use custom parameters to share data between scripts. For more information, see Custom and Proxy Parameters.

For more information about any of these features, refer to the documentation for your scripting language.

Several popular scripting languages are supported. To use a scripting language with XSI, you must first install the scripting engine for that language.

Supported Scripting Languages

You can write and run scripts using any language that is ActiveX-compliant. ActiveX is a technology for sharing data between programs. Examples of ActiveX-compliant scripting languages include:

• VBScript (the default)

• JScript

• PerlScript

• Python ActiveX Scripting

VBScript

VBScript is the default scripting language used by XSI. The XSI installation automatically includes VBScript on Linux and Windows, if it is not already installed. You can also download the Windows version and obtain further documentation from msdn.microsoft.com/scripting/

JScript

JScript is an ActiveX-compliant version of the JavaScript scripting language. The XSI installation automatically includes JScript on Linux and Windows, if it is not already installed. You can also download the Windows version and obtain further documentation from msdn.microsoft.com/scripting/

 

On Linux, only version 5.1 of JScript is supported. Among other things, this means that there is no built-in Array.Push method.

PerlScript

PerlScript is a version of the Perl scripting language that supports ActiveX. It is included in ActivePerl, which is available for Windows and can be downloaded from www.activestate.com/activeperl

 

With PerlScript, the scripting engine does not stop on errors. You cannot terminate using Ctrl+Break.

Python ActiveX Scripting

Python ActiveX Scripting is a version of the Python scripting language that supports ActiveX.

• On Windows, you must install Python ActiveX Scripting manually. See To install Python on Windows.

• On Linux, Python ActiveX Scripting is automatically installed with XSI. If you need to reinstall or update it, see To reinstall Python for Linux.

• To get XSI to use your Linux system’s PYTHONPATH environment variable, modify .xsi so that appends to the variable instead of overwriting it.

 

For troubleshooting tips related to Python, see the SDK Guides.

To install Python on Windows

1. Download and install Python (available from www.python.org).

2. Download and install pywin32 (formerly called win32all or win32com), Mark Hammond’s script extensions for Python (available from sourceforge.net/projects/pywin32/).

3. If Python still doesn’t appear in your XSI Scripting preferences, you need to run the following script in the directory where Python was installed:

\Lib\site-packages\win32comext\axscript\client\pyscript.py

To reinstall Python for Linux

If you need to reinstall Python for Linux or install a new version, follow these instructions:

1. Download the version of Python you want from www.python.org.

2. Build, install and configure Python:

- Use the following config option:

       --enable-shared

- You can also possibly use a custom prefix.

- Execute ldconfig to make the Python .so available.

Here is a command-line example of a typical build-to-configure process:

       % ./configure --enable-shared 
       % make 
       % sudo make install 
       % sudo /sbin/ldconfig 

3. Make sure that /usr/local/lib appears before $XSI_HOME/Application/ bin in your search path (/etc/ld.so.conf or LD_LIBRARY_PATH).

4. Start XSI and open the Scripting preferences. If the Python engine has been successfully registered, it appears in the list of possible languages to use in XSI.

Setting Your Preferred Scripting Language

Once you have installed an ActiveX scripting engine, you can set it as your preferred scripting language. The preferred scripting language is used to interpret commands when running them directly from the script editor or Command Box. It also determines the default extension when saving script files.

In addition, the preferred scripting language is used to log commands to the history if a deparser is available. If a deparser cannot be found when XSI starts, commands are logged in VBScript. If you change scripting languages during a session and a deparser cannot be found, the previous language is used for logging.

To set your preferred scripting language

1. Choose File > Preferences from the main menu.

The Preferences window opens.

2. Click Scripting.

3. Select an option from the Script Language pop-up list.

 

If you open a script file in a different language, it automatically changes the current scripting language that is set in your user preferences to the corresponding language.

 

The Scripting Language box lists the ActiveX scripting engines that are installed on your computer. If you just installed an engine and it is not listed, restart XSI. If it still isn’t listed, restart your operating system.

More Information About Scripting Languages

There are many additional sources of information on various scripting languages. While many of them are focused on web-page development, there are some that are more general.

 

All Internet addresses have been checked prior to publication. However because of the transient nature of the Internet, they may no longer be valid.

Windows Scripting Host (WSH)

• MSDN’s official WSH site: msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsoriWindowsScriptHost.asp

• DevGuru: www.devguru.com/Technologies/wsh/quickref/wsh_intro.html

• JScript examples and information about using the Windows Script Host, scripting Active Server Pages, Microsoft Office applications, etc. (Winscripter): www.borncity.com/WSHBazaar/WSHBazaar.htm

• Repository of scripts and information for Windows (Win32 Scripting): cwashington.netreach.net/

• Provides a monthly newsletter, Windows Scripting Solutions: www.win32scripting.com

• MSN’s Windows-Script: communities.msn.com/windowsscript

VBScript

• MSDN’s official VBS site: msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriVBScript.asp

• DevGuru: www.devguru.com/Technologies/vbscript/quickref/vbscript_intro.html

• Scripting tips and VBScript examples: www.ericphelps.com/scripting/

JScript

• MSDN’s official JS site: msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsoriJScript.asp

• DevGuru: www.devguru.com/Technologies/ecmascript/quickref/javascript_intro.html

PerlScript

• Official source for PerlScript: aspn.activestate.com/ASPN/Perl

• The Perl Directory (not specific to ActivePerl): www.perl.org/

• Perl.com (not specific to ActivePerl): www.perl.com/

• Perldoc.com (not specific to ActivePerl): www.perl.com/pub/q/documentation

Python

• Official Python Language Website (not specific to Python ActiveX Scripting): www.python.org/

• Introduction to Python (often used as textbook for high school programming classes): www.ibiblio.org/obp/thinkCSpy/

• For intermediate Python developers: www.mindview.net/Books/TIPython

• By programmers for programmers: diveintopython.org/

Other

• Part of Dr. Dobb’s Journal website, dedicated to scripting and alternative languages: www.ddj.com/topics/altlang



SOFTIMAGE|XSI v.6.01     

Return to Softimage XSI Index


Your Ad Here