View Full Version : having problems with a batch
09 September 2005, 10:05 AM
I am using maxscript to automate some boring stuff. The script takes a source destination and a target destination on each file and export each file to the destination directory
the problem i am getting is that after about half a dozen or so small test files maxscript brings up an Rollout Handler exception: Unknown system exception.
I have tried checking the heapsize and adding GC() to the end of the script. but that hasn't worked..
here is the script i got at the moment :
suffix = "_stable"
utility batch "Batcher" width:162 height:370
group "File Settings"
button btn1 "Select source directory"
label source ""
button btn2 "Select Destination directory" enabled:false
label dest ""
-- event handlers
on filenamesuffix entered text do
filenamesuffix.text = text
suffix = filenamesuffix.text
on btn1 pressed do
--Select source directory
sourcefiles = getSavePath caption:"Select Source Directory Containing .FBX files"
source.caption = sourcefiles
btn2.enabled = true
gofrom = sourcefiles
on btn2 pressed do
--Select Destination directory
targetfiles = getSavePath caption:"Select Destination Directory For .FBX files"
dest.caption = targetfiles
togo = targetfiles
on btn4 pressed do
--MessageBox "button Pressed"
type = "\\*.fbx (file:///*.fbx)"
files = getfiles (gofrom + type)
If files.count != 0 then
--run the batch
for f in files do
importFile f #noPrompt
max views redraw
--perfom some housekeeping functions parent the imported objects and delete some not needed
--make the new filename
exportFile (togo + "\\" + getFilenameFile f + suffix + ".FBX")#noPrompt
--error trap an empty folder
MessageBox "no .FBX Files in source directory doofus!"
)--end of file
Any idea whats happening?
09 September 2005, 05:49 PM
Ok I think i know whats hapening... for some reason the variable storing the filename is becoming undefined. and when its exported its causes the error, even though i set up a message box telling me the directory and the file thats about to be exported.
Does anyone know how this can happen as its already done like 10 files before it loses the location?
09 September 2005, 10:37 PM
Try this - written just for you! ;):
try (destroyDialog rdt_batchProcess;) catch ( );
rollout rdt_batchProcess "Batch Process..." width:344 height:208
button btn_source "Select source folder..." pos:[8,8] width:328 height:24
label lbl_filetype "Filetype:" pos:[8,40] width:136 height:16
edittext edt_filetype "" text:"*.*" pos:[152,40] width:184 height:16
button btn_dest "Select destination folder..." pos:[8,64] width:328 height:24 enabled:false
button btn_script "Select action script..." pos:[8,96] width:328 height:24 enabled:false
label lbl_prefix "Prefix:" pos:[8,128] width:136 height:16
edittext edt_prefix "" pos:[152,128] width:184 height:16
label lbl_suffix "Suffix:" pos:[8,152] width:136 height:16
edittext edt_suffix "" pos:[152,152] width:184 height:16
button btn_run "Run batch process" pos:[8,176] width:328 height:24 enabled:false
on btn_source pressed do
local sourceDir = getSavePath caption:"Select source folder...";
if sourceDir != undefined then
btn_dest.enabled = true;
btn_source.text = sourceDir;
on btn_dest pressed do
local destDir = getSavePath caption:"Select destination folder...";
if destDir != undefined then
btn_script.enabled = true;
btn_dest.text = destDir;
on btn_script pressed do
local scriptFile = getOpenFileName caption:"Select action script..." types:"MaxScript (*.ms)|*.ms|All files (*.*)|*.*|";
if scriptFile != undefined then
btn_run.enabled = true;
btn_script.text = scriptFile;
on btn_run pressed do
local sourceDir = (btn_source.text + "\\");
local sourceFileType = edt_filetype.text;
local destDir = (btn_dest.text + "\\");
local scriptFile = btn_script.text;
local prefixString = edt_prefix.text;
local suffixString = edt_suffix.text;
local sourceFiles = (getFiles (sourceDir + sourceFileType));
if sourceFiles.count == 0 then
print "Warning No Files Found!";
for eachItem in sourceFiles do
local sourceFilename = getfilenamefile eachItem;
local sourceExt = getfilenameType eachItem;
local destFile = (destDir + prefixString + sourceFilename + suffixString + sourceExt);
format "Source:\"%\"\nDestination:\"%\"\n" eachItem destFile;
if sourceExt as name == ".max" as name then loadMaxFile eachItem quiet:true;
else importFile eachItem #noPrompt;
max views redraw;
if sourceExt as name == ".max" as name then saveMaxFile destFile quiet:true;
else exportFile destFile #noPrompt;
09 September 2005, 09:58 AM
cheers impus appreciate this.
what was wrong with the script? I need to know so i can learn from my mistake :)
09 September 2005, 10:02 AM
well i gave it a whirl but i am still getting the error. but will continue to look into it.
i suspect that the scripts are calling the same variable or something....
09 September 2005, 04:02 PM
ok i think i got it. It appears to be a problem with the fbx exporter plugin. when i changed the format to export to it runs fine. if i switch it back it borks on me.
so for the moment the batch will have to export out to .max for the moment. can still work with it but at least the batch is working
thanks again for all your help there impus :)
09 September 2005, 04:09 PM
I have no idea what was wrong with your script. I actually just completely rewrote it. I think the problem you might be having is in your 'action script' maybe if you post that I can take a look?
09 September 2005, 05:03 PM
sorry Impus. cant do that :( its kind of a NDA sort of thing... but I managed to get it working but not having it export the file to .fbx Which is why i think it might actually be the .fbx exporter that might be causing the script to fail.
I will try some other versions of the fbx exporter in the meantime. and I will whip a mail off to alias to see if they have had any bug reports for their exporter.
again Impus many thanks for your help :)
09 September 2005, 05:03 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.