Notifications
Clear all

[Closed] Help with batch processing script

I’m afraid I’m totally new to maxscripting and need a bit of help.

Basically I need to bach process a load of max files using the Poly Trans for Max plugin from okino.com. I need to export as x files.

Here’s the example okino provide to export as 3ds files

– GetFilesRecursive… Get files recursively based on the passed root
– directory.

fn GetFilesRecursive root pattern =
(
dir_array = GetDirectories (root+”*”)

for d in dir_array do
(
join dir_array (GetDirectories (d+”*”))
)

my_files = #()
for f in dir_array do
(
join my_files (getFiles (f + pattern))
)
my_files
)


– Batch3DSFiles… Open all Max files and export as 3DS.


fn Batch3DSFiles root =
(
max file new

src_files = GetFilesRecursive root “*.max”

for f = 1 to src_files.count do
(
src_file = src_files[f]
dest_name = (GetFilenameFile src_file)
dest_file = (GetFilenamePath src_file) + dest_name + “.3ds”
print (“Exporting ” + src_file + ” to ” + dest_file)
LoadMaxFile src_file
PolyTrans.Export dest_file “” “.3ds” “” “” 0 0
)
print (“Export complete. ” + (src_files.count as string) + ” files exported.”)

)


– Run script

print “Exporting 3DS files…”
Batch3DSFiles “c:\max_files_to_be_exported\”

I made a folder called max_files_to_be_exported in C:\ and also in the Max root directory but get no files exported.

How would I edit this to get it to export x files and pick the folder with the max files in that I want to export to/import from… (this doesn’t work for me exporting 3DS files so its not just a case of changing 3DS to X – I’ve tried that)

Any help appreciated.

10 Replies

Hi,

You can change the end of the script like this:

------------------------------------------------------------------------------
 -- Run script
 --
 print "Exporting 3DS files..."
 inDir = getSavePath caption:"Please choose an input path for Max files."
 Batch3DSFiles inDir

The X files are exported in the inDir, in the same path/directory the Max files are.

Worked perfectly – mercie beaucoup! That will save me a lot of opening, saving, closing

To avoid unwanted behaviour when choosing cancel (inDir will be undefined value) add this:

------------------------------------------------------------------------------
 -- Run script
 --
 print "Exporting 3DS files..."
 inDir = getSavePath caption:"Please choose an input path for Max files."
 if inDir != undefined then Batch3DSFiles inDir

That works too – thanks again!

 PEN

I have finaly got around to releasing my batch processing script called Batch It Max.

You can find it here if you think this might help you. http://paulneale.com/scripts/batchItMax/batchItMax.htm

1 Reply
(@ypuech)
Joined: 11 months ago

Posts: 0

PEN, this is an interesting batch processing script.

I’ve also developed a small and simple batch processing script : http://ypuechweb.free.fr/batch_exporter.html

They both look like great tools – I’ll give them a run out. Many thanks – really has saved me a lot of work.

great scripts Paul and YPuech thanks for sharing.

that make me start to thinking about ideas of how to do pipes with bacth processing.

Pen could be sposible your script saves a increment file for each file. it could be good to have scriptable how the files are saved , so we can setup for each project diferent ways.

example:
save the file increment and move the old file to a working folder …

but thanks alot just going to have fun playing with the script.

pen could you coment for what you use batch maxfiles in your propduction , in what cases are useful for :).

 PEN

YPuech: Looks good, I can’t live without mine and it has saved me many times in production.

luigi: I have used it for many things. In one production the wrong version of a character had been used. The character needed a different out fit, so I set up a script that would swap one for the other and then batch processed about 150 files with the change over night.

I’m using it right now in a production where we have cleaned up mocap on a female character rig and I now need to get all the cleaned up data on to a male rig. So again, I set up a script to do the conversion and just let it run, in this case it is on about 800 files.

I have also used it for exporting animation cycles to a game where there were hundreds of cycles all in different files and I could batch process them out without having to be there.

The list goes on. Any time you need to make mass changes across many files then this is the way to do it.

I would include error checking in the script that you are going to run as I don’t remember if I wrapped a try()catch() around the fileIn. I probably did but I would still error check in the script as it would make it faster I think. Also make sure that your code is memory effiecient or as it proceses it will eventualy crash. That reminds me that I used it to batch Load/Save Animation from one character to another. Here I had memory issues but that was with loadSaveAnimation and there was nothing that I could do about it so I just had to process about 40 files at a time.

The log file that I added is handy as it will list the file that was processed, the date, user and the scripts that were run. I can add anything else that you might want. This is an old script and shouldn’t be used as reference for best practices…but it works.

Wow, pretty nice script congratulations Paul and ypuech, very usefull