Python – Getting the Softimage version numbers from the registry

This Python snippet will get the version numbers for the different versions of Softimage installed on the local system.

from _winreg import *
t = OpenKey(HKEY_LOCAL_MACHINE, r"SOFTWARE\Softimage\CoExistence", 0, KEY_READ )

    count = 0
    while 1:
		name = EnumKey(t, count)
		sKey = "SOFTWARE\Softimage\CoExistence\%s" % name
		t1 = OpenKey( t, name, 0, KEY_READ )
		value = QueryValueEx(t1, "AppVersion" )
		Application.LogMessage( "%s: %s" % (name.rsplit('|',3)[1], value[0]) )
		count = count + 1
except WindowsError:

On my machine, the script output looks like this:

# INFO : Softimage 2011 SP1:
# INFO : Softimage 2011 SP2:
# INFO : Softimage 2011 Subscription Advantage Pack SP1:
# INFO : Softimage 2011:
# INFO : Softimage 2012.SAP:
# INFO : Softimage 2012: 10.0.422.0
# INFO : Softimage 2013 SP1:
# INFO : Softimage 2013: 11.0.525.0
# INFO : Softimage_2010_SP1_x64:
# INFO : Softimage_2010_x64:
# INFO : Softimage_7.5_x64:
# INFO : XSI_7.01_x64: 7.01.698.0

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: - compatibility version: 1000
Application.OpenScene("C:\\Users\\blairs\\MyProject\\Scenes\\2012SAP_Scene.scn", "", "")

# INFO : 4034 - Loaded scene was created with build number: - 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")


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.