View Full Version : Max Script Batch stuff
tuxmask75
06-27-2011, 02:29 PM
Hey guys, I have around 600 or so .model files.
I already have a .model importer script for max.
it only opens files 1 at a time, and does not auto save.
what I'm trying to do is open multiple files within a directory and auto save them all in another format.
Anyone have a good max script that i could use to integrate within my other script.
((looking for something like Photo shop's batch function.))
Open
Save as: *file type*
Than open next file and repeat above.
haiddasalami
06-27-2011, 04:06 PM
Would help to know what file type. Will help people to point you to a script or possibly someone scripting it/tweaking a script to suit your needs.
Warheart
06-27-2011, 05:27 PM
Should be simple to do. Especially if all your files to be processed are in one directory then it's really easy.
files = getFiles "c:\\foo\\*.max"
for f in files do
(
loadMAXFile f; -- this would load each max file found in turn
-- so you would do something like:
-- call load function
-- save file
-- etc.
)
Obviously just changing the path to point to your folder and ".max" to be whatever extension you're looking for. If you want the script to handle subdirectories then it can get a little more complicated (e.g. if you want to mirror the directory structure within another root path or something like that). It's not that hard though and I'm sure myself or someone else here could help with that if it was needed.
If you search the maxScript help for "External File Methods" then there's more info about this type of stuff there.
tuxmask75
06-28-2011, 10:07 AM
Should be simple to do. Especially if all your files to be processed are in one directory then it's really easy.
files = getFiles "c:\\foo\\*.max"
for f in files do
(
loadMAXFile f; -- this would load each max file found in turn
-- so you would do something like:
-- call load function
-- save file
-- etc.
)
Obviously just changing the path to point to your folder and ".max" to be whatever extension you're looking for. If you want the script to handle subdirectories then it can get a little more complicated (e.g. if you want to mirror the directory structure within another root path or something like that). It's not that hard though and I'm sure myself or someone else here could help with that if it was needed.
If you search the maxScript help for "External File Methods" then there's more info about this type of stuff there.
Yeah something like that,
and loadMAXFile f; would need to load a .model so I'm guessing this needs to be changed?
Would help to know what file type. Will help people to point you to a script or possibly someone scripting it/tweaking a script to suit your needs.
.fbx .dae .obj .3ds .max are the export formats I'm interested in,
and .model is import.
r_fletch_r
06-28-2011, 10:27 AM
inFormat = ".model" --put your in format here
outFormat = ".dae" -- put your out format here
files = getFiles "c:\\foo\\*."+ inFormat
for f in files do
(
importFile f #noPrompt
newFilename = (filterString f ".")[1] + outFormat
exportFile newFilename #noPrompt
)
this should do it. havent tested it but is not exactly complex.. I dont know whether all formats support the #noPrompt flag so you may be clicking through UI's a bit. but thats not avoidable.
Warheart
06-28-2011, 12:14 PM
Ah ok, sorry I didn't explain that in much detail because I was assuming you were reasonably familiar with the scripting stuff.
Yea, like you said you need to replace that loadMAXFile function call with your import function. e.g. "importModelFile f" (assuming it's got a load function that accepts the path to a file as an argument).
Is it your import script? If not and you're not sure how it works then it might be worth posting it or a link to where you got it from and we can help modify/wrap it to do this.
Edit:
Just saw r_fletch_r's post. Yea, that should work assuming your .model reader is a plugin and not a script.
tuxmask75
07-03-2011, 06:36 AM
Ah OK, sorry I didn't explain that in much detail because I was assuming you were reasonably familiar with the scripting stuff.
Yea, like you said you need to replace that loadMAXFile function call with your import function. e.g. "importModelFile f" (assuming it's got a load function that accepts the path to a file as an argument).
Is it your import script? If not and you're not sure how it works then it might be worth posting it or a link to where you got it from and we can help modify/wrap it to do this.
Edit:
Just saw r_fletch_r's post. Yea, that should work assuming your .model reader is a plugin and not a script.
Yeah the .model reader is a script.
vBulletin® v3.8.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.