I've written a batch exporter using bits and pieces of code I've cobbled together. src_files is an array that stores a list of max files to export. There a few variables which store whether or not to save a max file, which units to set and save locations of the max files and export flt files.
The exporter works really well, however I tried running it on a folder of over 500 max files, but it would crash with certain files. I will get an unknown system exeption error. Then in the listener I get "Error occurred in f loop; .." and it stops on the LoadMaxFile line.
Is there a way to script it so that instead of crashing on LoadMaxfile it will return to the loop and log the files it can't load?
Here's the main part of the exporting loop:
if src_files.count != 0 then
(
max file new
units.DisplayType=#us
units.SystemType=reScale
for f = 1 to src_files.count do
(
--LoadMaxFile "C:\\blankfile.max" quiet:true useFileUnits:true
--units.DisplayType=#us
--units.SystemType=reScale
src_file = src_files[f]
dest_name = (GetFilenameFile src_file)
dest_file = VexportFLT + "\\" +dest_name + ".flt"
missingDLLs = undefined
missingExt = undefined
LoadMaxFile src_file quiet:true useFileUnits:false missingExtFilesAction:#logmsg missingExtFilesList:&missingExt missingDLLsList:&missingDLLs missingDLLsAction:#logmsg
print ("Exporting " + src_file + " to " + dest_file)
PolyTrans.Export dest_file "" ".flt" "" "" 0 0
if VexportMaxState == "true" then
(
--Save max file
saveMaxFile(VexportMax + "\\" + maxFileName)--save new max file
print ("Saved max file")
)
)
messagebox ("Export complete. " + (src_files.count as string) + " files exported.")
)
else
(
messagebox ("No Max files found in batch export location")
)
I think I've pinned down the files that it's having difficulty loading, but the files actually load OK when opening them in max as normal. If I collapse the stacks, reset the Xforms and then save, the exporter will work as usual. If I could automate this into the exporter that would be great but since they won't load through the loadMaxFile function I've no idea how to do that! :shifty:
I forgot to say I don't think it's a memory error since when running the script on the broken files alone, the script will still crash. I did try increasing the memory available to max script but that didn't help.
EDIT: I also tried creating a blank max file and loading this first in the loop so it would always go file1 > blank > file2 > blank etc rather than go file1 > file2 > file3. This made no difference.
Replies
I tried using PENs great batch exporting script with the following script to try and clean up the files before export:
What happens is the script will save say 2 max files then crash with unknown system error at the convertTo g PolyMeshObject line. Am I doing something wrong?
I also tidied up the script so that it didn't save during the loop as my intention was to save a before and after file.
Ffor example say MyMaxFiles is an Array of max file names. The following code will try to export all files. If there is an exception, the loop will skip the error and print the file name to the listener.