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.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:
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(":").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
LogMessage( version )
And here’s a Python snippet:
scn = 'C:\\Users\\blairs\\Documents\\Support\\Project\\Scenes\\MySphere.scn'
p = subprocess.Popen( 'printver -l %s' % scn, stdout=subprocess.PIPE )
stdout = p.stdout.readlines()
See the thread on the Softimage mailing list, which includes a VBScript snippet for getting the build version.