#include statement in JScript


JScript doesn’t include anything like the #include statement, or like modules in Python.

But what you can do is read the contents of a file into a string, and then eval() the string. For example:

var fso = ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile( "//server/scripts/toinclude.js", ForReading );
var s = f.ReadAll();
eval(s);
s.Close();

Note that if there’s any errors in the included code, you won’t get the right line numbers in the error messages.

In JScript, another approach would be to create a custom object that has all the helper functions as methods. For an example of that kind of thing, check out the WizardHelperObj object in

%XSI_HOME%\Addons\sdkui\Application\Plugins\SDKWizards.js

Then you just provide one custom command that returns an instance of the custom object to whatever code needs to use the helper functions.

The case where there was no way to disable Face Robot


I’ve seen a few cases where a user couldn’t disable Face Robot, because there was no Face Robot module or menu.

That’s because the module menus were hidden. To show the module menus, right click and empty area on the Softimage menu bar, and click Module Menus.\

Then you can click Face Robot > Disable Face Robot.

Copying tangent data in a crowd


Here’s a video walkthrough that shows how to get tangent data on the source actor and copy it to the actor copies. It’s basically a two-step process: first, copy the tangent data to a custom attribute on the mesh proxy, and the copy the attribute from the proxy to the actor copies. That’s basically what CrowdFX does for you for the default Texture_Projection.

I did this video for a customer who wanted the tangent data for the normal maps on the actor copies.

Copying tangent data with ICE modeling


Here’s an example of using Copy PolyNode Data from Source to copy tangent data from a source mesh to a cloned mesh. Typically you would plug this into the Execute on Copy port of a Create Copies from Polygon Mesh or Clone Polygon Mesh, but here I’ve done something more basic.

To display the tangent data of the clone in the viewport, I’m using the Vertex Color Display Property setting (OpenGL Display tab of the material applied to the clone).

More on getting the version of Softimage used to create a scene


Whenever you open a scene, you’ll see a message like this logged to the script history:

# INFO : 4034 - Loaded scene was created with build number: 10.5.98.0 - compatibility version: 1000
Application.OpenScene("C:\\Users\\blairs\\MyProject\\Scenes\\2012SAP_Scene.scn", "", "")

# INFO : 4034 - Loaded scene was created with build number: 10.1.62.0 - compatibility version: 1000
Application.OpenScene("C:\\Users\\blairs\\MyProject\\Scenes\\2012SP1_Scene.scn", "", "")

If you want to know the version of Softimage that was used to create the scene, you need to check the specific build number (and there’s a couple of ways to do that, we’ll get to that in a second…).

The compatibility version is more a property of Softimage itself than of the scene. You can get the value of the project.CompatibilityVersion parameter, but it’s always going to be the compatibilty version of the current Softimage instance, not of the loaded scene.

p = Application.Dictionary.GetObject( "project.CompatibilityVersion" )
print Application.ClassName(p)
print p.Value

# OR

print Application.GetValue( "project.CompatibilityVersion" )

To find out the version of Softimage used to “build” a scene, you can use the printver utility, or look in the scntoc file. In this context, “build” means the version of Softimage that was last used to save the scene. I note that just opening a scene and saving it isn’t enough to bump up the build version. You need to do something to the scene, or at least do something and then undo it.

From Jeremie Passerin on the Softimage mailing list, here’s a Python snippet that reads the version from the scntoc:

# Python Code
import xml.etree.ElementTree as etree

ext = 'scntoc'
scn = 'C:\\Users\\blairs\\Project\\Scenes\\Test.%s' % ext

tree = etree.parse( scn )
root = tree.getroot()
version = root.get("xsi_version")

LogMessage(version)

Here’s a JScript snippet that reads the version from the scntoc:

var dom = new ActiveXObject("msxml2.DOMDocument.6.0");
dom.async = false;
dom.resolveExternals = false;

ext = 'scntoc';
scntoc = 'C:\\Users\\blairs\\Project\\Scenes\\Test.' + ext;

dom.load( scntoc );
var oNode = dom.selectSingleNode("xsi_file");
LogMessage( oNode.getAttribute( "xsi_version" ) );

If you don’t want to rely on the existence of a scntoc, you could use the printver.exe utility that ships with Softimage. Given a scene file, printver prints a message that looks like “This Scene was built with version: 11.0.525.0”.

Here’s a JScript snippet that runs printver and gets the version number from STDOUT:

// JScript
var WshShell = new ActiveXObject("WScript.Shell");

scn = "\\\\server\\Project\\Scenes\\Whatever.scn"

sExec = "printver " + scn

var oExec    = WshShell.Exec( sExec );

while ( !oExec.StdOut.AtEndOfStream )
{
	s = oExec.StdOut.ReadLine();
	if ( s.indexOf("This Scene was built with version") != -1 )
	{
		var version = s.split(":")[1].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	}
}

LogMessage( version )

And here’s a Python snippet:

import subprocess

scn = 'C:\\Users\\blairs\\Documents\\Support\\Project\\Scenes\\MySphere.scn'
p = subprocess.Popen( 'printver -l %s' % scn, stdout=subprocess.PIPE )
stdout = p.stdout.readlines()
print stdout
print stdout[-1].split(':')[1].lstrip().rstrip()

See the thread on the Softimage mailing list, which includes a VBScript snippet for getting the build version.

New Tool: ICE Tree Trace from Bradley Gabe


ICE Tree Trace is a new tool from Bradley Gabe. Download it here.

It’s a plugin, so you want to save it in the Application\Plugins folder of either your Softimage User location, or of a workgroup.

Or drag this addon to a viewport.

After you install the plugin, you’ll have a new menu in the ICE Tree view:

ICE_TraceRefString:
Tool for tracing instances of strings inside ICE Trees. Can be used, for example, to track down the number of times a specific attribute is called. Via filters, may also be used to determine how an attribute is called, whether by Get Data, Set Data, or other ICE nodes that handle string parameters.

Here’s an example. I used Tree Trace to find all references to the Texture_Projection attribute in a CrowdFX scene:

Usage:
Specify search options, enter a Match String, then press the trace button. If matches are found, the address of the ICE Nodes are listed in the Match List at the bottom of the GUI. If items are selected in the Match List, their corresponding nodes are selected in the scene

NOTE: At present, there is no access in the SDK to directly select nodes inside an ICE Tree node graph interface. ICE nodes are selected in the scene, and may be accessed via the explorer.

GUI Parameters:
Search Scope:
• Selected ICE Nodes – Search only within currently selected nodes in ICE Tree
• Local ICE Tree – Search all nodes in the currently open ICE Tree
• ICE Trees on Sel Scene Items – Any ICE Tree on selected scene items
• Global Scene – All ICE Trees in the scene

ICE Node Filter:
• All ICE Nodes – No filter
• Get Data only – Search for string matches only in Get Data nodes
• Set Data only – Search for string matches only in Set Data nodes
• Other Nodes – Search for string matches in nodes that are not Get Data or Set Data (Shape Instance, String nodes, etc)

Match String: String to be searched for inside ICE Tree

Cap Sensitive: Consider capitalization in search string (Overridden by RegExpr matching)

Use Regular Expression Matching: Allows user to specify match strings using regular expression syntax

Checking the version used to create a scene


If you can live with the flash of a command prompt window, you can use subprocess.Popen to get the scene file version from printver.

import subprocess

scn = 'C:\\Softimage\\XSI-EXP_3.0\\Data\\XSI_SAMPLES\\Scenes\\dog.scn'
p = subprocess.Popen( 'printver %s' % scn, stdout=subprocess.PIPE )
stdout = p.stdout.readlines()
print stdout[-1].split(':')[1].lstrip().rstrip()
# 3.0.2002.0715


#scn = 'C:\\Softimage\\XSI_7.01_x64\\Data\\XSI_SAMPLES\\Scenes\\ICE\\Particle_Basic_Fire.scn'
# 7.0.2008.0708