Get Scene File Version

107 views
Skip to first unread message

Martin

unread,
May 10, 2012, 12:37:07 PM5/10/12
to soft...@listproc.autodesk.com
Hi, how can I get a Scene File version with scripting?

I know that when I open a file, SI logs the scene version. I also know that I can get the version opening the toc file with a text editor, and use printver.exe to display the version in a Command Prompt. But I want to do it from inside SI.

The reason is that I have to work with different SI versions for different projects, and sometimes I open a file from SI 2010 in SI 2012 when I shouldn't, and a few times I even save the file! and since SI have zero forward compatibility I'm totally screwed when I do that. So I was thinking in creating an event to check the file version and compare it with the SI version and get a warning message if they don't match, but I have no idea how to get a file's version.

Is it possible?

Thanks,

M.Yara

Peter Agg

unread,
May 10, 2012, 12:39:30 PM5/10/12
to soft...@listproc.autodesk.com
print Application.Version()

:)

Stephen Blair

unread,
May 10, 2012, 12:39:48 PM5/10/12
to soft...@listproc.autodesk.com
Application.Version()
winmail.dat

Martin

unread,
May 10, 2012, 12:46:32 PM5/10/12
to soft...@listproc.autodesk.com
I know that one, but as far as I know it onlly gives me the Softimage Application version, not the scene file.

When I log Application.Version in 2012 I get:
10.0.422.0

And when I open an old file, SI logs something like :
Loaded scene was created with build number: 8.0.201.0 

This last one is the version number I want to get so I can compare it with Application.Version.

M.Yara

Stephen Blair

unread,
May 10, 2012, 12:59:51 PM5/10/12
to soft...@listproc.autodesk.com
Sorry about that. The last time this came up, using printver.exe was the best suggestion.
winmail.dat

Jeremie Passerin

unread,
May 10, 2012, 1:00:36 PM5/10/12
to soft...@listproc.autodesk.com
You have it in the scntoc :

<xsi_file type="SceneTOC" xsi_version="8.0.249.0" syntax_version="2.0">

Jeremie Passerin

unread,
May 10, 2012, 1:05:04 PM5/10/12
to soft...@listproc.autodesk.com
You could read the scntoc in Softimage :

# Python Code
import xml.etree.ElementTree as etree

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

LogMessage(version)

Alan Fregtman

unread,
May 10, 2012, 1:18:21 PM5/10/12
to soft...@listproc.autodesk.com
That's a good way.

One time I opened a .scn with WinRAR by accident and to my surprise, it was a compressed archive with several files, one of which contained the scene version quite plainly. Scene data, however, was binary.

It made me ponder if one could edit the version file or at least swap it with that of an older version, would the scene still open if no new features were used? Oh the mysteries...

Martin

unread,
May 10, 2012, 1:43:51 PM5/10/12
to soft...@listproc.autodesk.com
 Thanks. The problem is that I don't always have a scntoc.

I guess I'll have to manage a way to use printver.exe.


M.Yara

Jeremie Passerin

unread,
May 10, 2012, 2:30:09 PM5/10/12
to soft...@listproc.autodesk.com
"One time I opened a .scn with WinRAR by accident and to my surprise, it was a compressed archive with several files"

really  ?
I gave it a quick try... and it's not working for me :-|

Alan Fregtman

unread,
May 10, 2012, 3:02:33 PM5/10/12
to soft...@listproc.autodesk.com
Actually, it might have been an *.emdl now that I think about it.

Jens Lindgren

unread,
May 10, 2012, 4:28:14 PM5/10/12
to soft...@listproc.autodesk.com
I just tried both a .scn and .emdl and none of them worked :(

--
Jens Lindgren
--------------------------
Lead Technical Director

Sajjad Amjad

unread,
May 11, 2012, 5:02:34 AM5/11/12
to soft...@listproc.autodesk.com
Depending on the complexity of control you want, the following may not work.
You could make a custom preference file per project. These preferences, amongst other things, could hold what app versions are allowed. A beginsceneload event could then check that the correct app version is the host.

Chris Chia

unread,
May 11, 2012, 9:33:08 AM5/11/12
to soft...@listproc.autodesk.com
The best option is thru scntoc to find the version.
If it is not generated, please check your preference > Tools > Data Management > Scene File Options
for the Scene TOC options.
Cheers.

Regards,
Chris Chia

________________________________
From: softimag...@listproc.autodesk.com [softimag...@listproc.autodesk.com] on behalf of Martin [furi...@gmail.com]
Sent: Friday, May 11, 2012 1:43 AM
To: soft...@listproc.autodesk.com
Subject: Re: Get Scene File Version

winmail.dat

Martin yara

unread,
May 12, 2012, 4:49:03 AM5/12/12
to soft...@listproc.autodesk.com
Thanks for your replies.

I know how to generate scntoc files but that doesn't help me. I have
to check different files from different persons, projects and
different SI versions, and not all of those scenes have a scntoc file.
Sometimes I open them in a higher version SI and make the mistake to
save and overwrite them. (not very often and always have backups but I
would like to prevent a disaster.)

So far I wrote an event to trigger before saving, get the file version
through printver.exe and compare this version with the app.version and
if the major number doesn't match open a warning msgbox to cancel or
proceed.

I don't know yet how to get the printver result directly into SI so
I'm using > txt and then read that txt file.

M.Yara
> <winmail.dat>

Stephen Blair

unread,
May 12, 2012, 6:40:56 AM5/12/12
to soft...@listproc.autodesk.com
Hi

Here's one way to get the info from printver
http://xsisupport.wordpress.com/2012/05/12/checking-the-version-used-to-create-a-scene/




Stephen Blair
M&E Technical Lead, Product Support
Global Services

Autodesk, Inc.
Montreal, Quebec, Canada
Blog: http://xsisupport.wordpress.com

________________________________________
From: softimag...@listproc.autodesk.com [softimag...@listproc.autodesk.com] on behalf of Martin yara [furi...@gmail.com]
Sent: Saturday, May 12, 2012 4:49 AM
winmail.dat

Martin

unread,
May 13, 2012, 3:12:20 AM5/13/12
to soft...@listproc.autodesk.com
Thanks for the tips Stephen.

I just cleaned up my code and decided to keep my printver.exe > txt version because it is a little more "transparent".

I wrote it in vbs to use FSO and WSH.
If anyone is interested:

Event Function Code:

function siOnBeginSceneSaveEvent_OnEvent( in_ctxt )
   Application.LogMessage "siOnBeginSceneSaveEvent_OnEvent called",siVerbose

   FilePath = Application.ActiveProject2.ActiveScene.filename.value
   splitFilePath = Split(FilePath, "\")
   ScnName = splitFilePath(Ubound(splitFilePath))

   if ScnName <> "Untitled.scn" then
      TempPath = XSIUtils.Environment("TEMP")
      BinPath = XSIUtils.Environment("XSI_BINDIR")

      set FSO = CreateObject( "Scripting.FileSystemObject" )
      set WshShell = CreateObject( "WScript.Shell" )

   'Run PrintVer and print result to a txt file
      WshShell.run "cmd /c printver.exe " & FilePath & " > " & TempPath & "\ver.txt" & """", 0, 1
      
   'Get File Version (Read Text)
      GetVer = FSO.OpenTextFile(TempPath & "\ver.txt", 1).ReadLine
      FileVer = Right(GetVer, Len(GetVer) - InStr(GetVer, ": ") -1)
      FileVerMaj = Split(FileVer, ".")(0)
   'Delete Text
      FSO.DeleteFile TempPath & "\ver.txt"
      
   'Get App Version and Compare
      AppVer = Application.Version
      AppVerMaj = Split(AppVer, ".")(0)
      
      if AppVerMaj <> FileVerMaj then
         logmessage "-----------------------------------------------------"
         logmessage "Current Scene File Version : " & FileVer
         logmessage "Softimage Version          : " & AppVer
         logmessage "-----------------------------------------------------"
         SaveQuestion = Msgbox ("You are going to save in a newer Softimage version." & vbNewline & vbNewline & "Are you sure?", 1 + 48, "Different Version Warning")
      end if

      if SaveQuestion = 2 then
         logmessage "Scene not saved - Command was cancelled.", siWarning
         siOnBeginSceneSaveEvent_OnEvent = True
      else 
         logmessage "Scene Saved"
         siOnBeginSceneSaveEvent_OnEvent = False
      end if

   else
      siOnBeginSceneSaveEvent_OnEvent = False
   end if
   
end function

M.Yara
Reply all
Reply to author
Forward
0 new messages