PDA

View Full Version : Is it possible to read text from script history?


Dennis Leong
03-20-2008, 03:18 PM
I'm not sure if this is possible, and I've scoured the SDK docs to find a way to do this but I'm out of ideas.

What I'd like to do is write a plugin so that when a scene is saved all the text in the script history window gets written to an annotation in the scene root. This would make it easier to troubleshoot scenes when something goes awry and the animator can't remember what they did since the last save. We have a custom save manager to write iterations of scenes so I don't have to worry about overwriting the previous annotations.

As far as I can tell, I can only retrieve selected text in the script history window using the View.GetAttributeValue("historyline") command. The SDK docs state that if there is nothing selected then the function will return the last script history line, although I only get an empty string when I do this.

Here's my bit of code (vbscript) to create the script history view and then spit back out some text (in this case, an empty string because nothing is selected in the script history window.)

' Get the view if it exists, or create it.
dim view : set view = Desktop.ActiveLayout.Views("Script History")
if typename(view) <> "View" then set view = Desktop.ActiveLayout.CreateView("Script History", "Script History")

' Grab the selected text in the script history view. If no text is selected, the function
' is supposed to return the current script history line (it doesn't seem to do that.)
dim historyText : historyText = view.GetAttributeValue("historyline")

' Output the text we grabbed.
MsgBox historyText, vbOKOnly, "Script History Text"If you ran this without a script history window open, it will create a script history window for you and probably output nothing. If you select some text in the script history window and run the code again, the vbscript message box will report the selected text.

So my question is: can I can get ALL the text in the script history window without asking the animator to manually select the entire script history?

I know I can set XSI preferences to log all script commands to an external file, but this file gets replaced once a new XSI is loaded (and I don't know how this works if multiple XSIs are loaded.) I've tried opening the script log file and reading from it to grab the info I need but the file is locked when XSI is still running.

I'm running XSI 6.5 on win32. If anyone has any ideas, please post!

StephenBlair
03-20-2008, 05:08 PM
There are no hidden/undocumented attributes for the History Log, at least not that last time I searched the code.

Maybe you should look into modifying XSI.bat to save the previous session's script log before XSI starts.
And use that together with some events like OnStartup, OnNewScene, OnOpenScene, OnSave. eg OnOpenScene would LogMessage some kind of delimiter.

Either that or figure out how to access that locked file :-)

Dennis Leong
03-25-2008, 05:17 PM
Thanks for your help! I'll try to think of something... maybe a video camera behind the shoulder of each animator to catch what they're doing and make sure they're not slacking off!

Atyss
03-27-2008, 11:34 PM
If you use the events Stephen mentioned to change the name of the log file, you'll get access the previous log file.

Let say in a OnBeginSceneSave event you record the name of the log file, you store it in the global scope with SetGlobal(). In the same event, you change the name. What happens is that the log file gets closed (and thus becomes readable), and a new one is created. Using GetGlobal(), you can find out what was the previous log file file name, open that file, and extract the text you want from it.

Just a thought.


Cheers
Bernard

kim aldis
04-08-2008, 02:12 PM
There are no hidden/undocumented attributes for the History Log

Ah, but if they're hidden how would you know they're there?

Glasshopper.

StephenBlair
04-08-2008, 07:55 PM
Hidden from you, not from me :-)

kim aldis
04-09-2008, 03:22 AM
Elitist.
------------------