[Closed] [MXS] LoadSaveAnimation.saveAnimation …getting Unknown system exception
Ok… thanks to @denisT I added a snippet to my maxscript XSI importer to allow option to save the imported animation to .XAF file format.
I added this XAF snippet just after it saved the newly imported scene… and before iterating onto the next XSI file in the import file list.
SNIPPET:
max tool zoomextents all
--saveMaxFile tempFileName
if ( saveMaxFile tempFileName ) do (
format "File saved as %
" (getFilenameFile tempFileName + ".max")
)
collectGarbage = gc()
--save XAF animation file
if bSaveXAF == true do (
--verify reservoir directory exists
reservoirValid = (getDirectories reservoirPath)
if reservoirValid.count < 1 do ( makeDir reservoirPath )
xafFilename = (reservoirPath + "\\" + (getFilenameFile tempFileName) + ".xaf")
max select all
LoadSaveAnimation.saveAnimation xafFilename ($selection as array) "" ""
max select none
format "Animation saved to XAF reservoir [%]
" (reservoirPath)
)
It will successfully process a few files and then suddenly highlight the “LoadSaveAnimation” line and give me an “unknown system exception”. I thought this might be due to running low on memory… so I added a line to manually do garbage collection at the end of each iteration. But that does not resolve these crashes.
Listener output:
<File:C:\TEMP\convert\hazard\console1idle.xsi> …import successful!
File saved as console1idle.max– Error occurred in i loop; filename: C:\Users\LawlerMA\Desktop\XSI_Importer_v2.0_Beta_R9_XAF.ms; position: 106464
– Frame:
– header: #(“xsi”, “0101txt”, “0032”)
– tempFileName: “C:\TEMP\convert\hazard\console1idle”
– collectGarbage: 51718252
– xafFilename: “C:\TEMP\XAF\hazard\console1idle.xaf”
– afterHeader: 17
– i: 4
– reservoirValid: #(“C:\TEMP\XAF\hazard”)
– called in btn_Import.pressed(); filename: C:\Users\LawlerMA\Desktop\XSI_Importer_v2.0_Beta_R9_XAF.ms; position: 106866
– Frame:
– tempFileName: undefined
– xafFilename: undefined
– reservoirValid: undefined
>> MAXScript Rollout Handler Exception: – Unknown system exception <<
Importing a single file (i.e., batch processing not checked) works just fine. But I have hundreds of files to process.
After the exception pops up and halts batch processing (bringing up the script)… I can even highlight that XAF snippet and press an Enter on keyboard (after manually ensuring that the needed variables are defined in the scope of the Listener) and it will save the XAF just fine.
Any suggestions?
there is something in the ‘failed’ scene that doesn’t like to be exported with LoadSaveAnimation interface
you have to figure out what it is…
LoadSaveAnimation has “prepare to export” methods. try to isolate the node(s) that causes the failure.
Also it’s better to export only animation data that you really need specifying it with setUpAnimsForSave or by list of nodes using saveAnimationNodeAnim
Thanks… these are old humanoid game animations (basically baked per frame FK animations of the game skeleton)
I modified the script to append to an empty node array using isValidNode() and so far it has not crashed… and is still chugging along.
Revised snippet:
--save XAF animation file
if bSaveXAF == true do (
--verify reservoir directory exists
reservoirValid = (getDirectories reservoirPath)
if reservoirValid.count < 1 do ( makeDir reservoirPath )
xafFilename = (reservoirPath + "\\" + (getFilenameFile tempFileName) + ".xaf")
max select all
tempSceneNodes = #()
for s in selection where isValidNode s do ( append tempSceneNodes s )
if tempSceneNodes.count > 0 do (
try(LoadSaveAnimation.saveAnimation xafFilename tempSceneNodes "" "")
catch
(
gc()
LoadSaveAnimation.saveAnimation xafFilename tempSceneNodes "" ""
)
)
max select none
format "Animation saved to XAF reservoir [%]
" (reservoirPath)
)
You are right, I should use methods to try to find the offending node… because perhaps my isValidNode check is throwing some important nodes out?
I plan to re-target these animations onto my new character rig using a file mapping…
Update: So it processed 116 of the remaining 238 files before crapping out with the “unknown system exception”. The script failed at the LoadSaveAnimation in the catch statement (see the snippet in previous post).
I will go back and spot check a few and see how they came thru.
It seems to be random files… but always on the LoadSaveAnimation line… now in the catch() line.
Maybe now it’s a memory thing? It has only crashed twice since my last edit above.
When I do a check of scene nodes against the node count from isValidNode(), they are always equal.
It is still chugging along… so far it has processed 71 of the remaining 111 animations.
I can live with this as a bug I guess… what I don’t understand is why my script fails to work for Max2013 and later versions… Maybe something is deprecated? Works like a charm in Max8 thru Max 2011.
I’m happy to share it here if you like– it’s a beast of a script. It brute-force parses Softimage ascii dotXSI files (v1.1,1.3, 3.0, 3.5). It is the only tool available to import the ancient 1.x XSI files.
And it does a proper coordinate transformation on all nodes from the +Y up XSI coordinate system to the 3ds Max +Z up coordinate system (unlike some plugins that only rotate the root node 90 degrees about X axis– which leaves all nodes in the heirarchy still in the XSI coordinate system).
ok… lets say it’s memory(gc) issue.
try to make the batch process as safe as possible:
#1 don’t use try() catch() because it never helps in our case
#2 don’t use gc()
#3 use resetMaxFile #noPrompt every time before load next max file
#4 use freeSceneBitmaps() in pair with reset max file
#0 set Max Script initial allocated heap at least 128 (MBytes)
== don’t change heap allocation dynamically (if we have a leak we have to know it)
== print to a log file memory stage before and after every export…
#5 do for example completeredraw() before every export (to force scene update)
Thanks Denis, I will try to apply your recommendations. I did my best to avoid using try/catch… but there were some unexplainable issues where it failed to add my custom attributes to the scene nodes and all I could think to do was to use try/catch until it succeeded adding the custom attributes.
In v2.0 Beta R9, I added assignment of vertex normals to an Edit Normals modifier. But based on these imported meshes I think I did not do a proper transform on the normals… so I need to fix that. But that does not matter for the skeletal animation data itself.
In v2.0 Beta R10, I added the save to XAF feature for retargeting.
The script is attached. I need to fix the import on the vertex normals assigned to the EditNormals modifier.
For dotXSI v3.0/3.5 files use the game preset #3, if you had any legacy v1.x dotXSI files use the game preset #2.
@denisT – If you would like to test out my importer script based upon some of your own animations. Then use my dotXSI v3.0 Exporter plugin available at maxplugins.de (it supports Max6 thru Max2017).
very unlikely i will find a time to look into the code (and i don’t have any < max 2014 available anyway)
about using of try() catch()
the only possible excuse of using of try/catch is – “I know it crashes here, I know why, but I can do nothing with it.”