In 3ds max 2018 Update 4 we've revamped how 3ds Max Batch works, where previously it was using the -batch flag now it's the maxbatch.exe executable.
The areas that we've changed are (for the detailed explanation please see Using 3ds Max Batch in the online help).
1. New options to pass data to the script:
|mxsString||to pass a string to the script|
|mxsValue||to pass the result of evaluating the string to the script|
2. Clearer error codes and logging:
|-listenerlog||file to use for listener output|
|-log||file to use for script error and exceptions|
3. More options to control 3ds Max Batch:
|-i||3dsmax.ini file to use|
|-p||plugin.ini to use|
|-dm||use the dialog monitor|
|-sceneFile||scene file to open before the script is run|
So with that we go into a simple example: similar to a post from years ago (https://area.autodesk.com/blogs/max-station/nh7_using_backburner_to_automate_tasks_other_than_rendering_part_2/) I want to add some geometry to my scene files.
The difference is that this time I'm not submitting this via Backburner (that's for another post), I'll create two version, one Maxscript and one in python and I'll try to make the most of the new options that are available.
- 3dsmaxbatch.exe add_a_box.ms -mxsString filename:"//fara06253/backburner/test.max" boxname:"test_ms" -log "c:\Temp\max_ms.log"
- 3dsmaxbatch.exe add_a_box.py -mxsString filename:"//fara06253/backburner/test.max" boxname:"test_py" -log "c:\Temp\max_py.log"
I'm passing the filename in the filename mxsString and the name for the box that will be created in the boxname mxsString.
The reason I'm passing the filename is that I want to be able to save it under another name by adding a postfix to the name. If I'd just wanted to save it under the same name I could have used the command line parameter -sceneFile.
Note that I'm using forward slashes as that's a lot less confusing than trying to escape back slashes (check the number of back slashes in the original post!). Finally I'm writing the output to a specific log file so that I could parse that in case I need to get hold of some information.
You can use echo %ERRORLEVEL% to print the result of the 3dsmaxbatch executable, if all went fine it'll be 0.