This topic covers using 3ds Max Batch included in 3ds Max 2018.4 Update and later. To use the 3ds Max Batch included in 3ds Max 2018.2 and 2018.3 Updates, see Using 3ds Max Batch Legacy.
3dsmaxbatch.exe <script_file> [options]
In this syntax, <script_file> is the name of a MAXScript or Python script, and is a required parameter. 3ds Max Batch automatically detects the script type.
3ds Max Batch starts and loads the specified 3ds Max scene file (if one is provided - this is an optional parameter). It then executes the script_file and any additional inputs if any are provided. It then exits.
You can pass one or more of the following as options to 3dsmaxbatch.exe.
System log verbosity level. Valid arguments are:
The default is 2.
Date format string for the console log. For example, "yyyy-MM-dd" or "ddd, MM/dd/yyyy"
See https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings for a description of date and time string formats.
Time format string for the console log. For example, "hh:mm:ss" or "ss : mm"
See https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings for a description of date and time string formats.
The 3ds Max config file (.ini). Defaults to the per-user default config file (3dsmax.ini).
The 3ds Max Plugin config file (.ini). Defaults to the per-user default plugin config file (Plugin.UserSettings.ini)
See the "Plugin.ini" topic in the 3ds Max Developer's Guide for more information
The 3ds Max Listener log file to capture output from the listener. No listener log is created by default.
See the "Turning On the Listener Log" topic in the MAXScript Guide for more information.
The 3ds Max system log file. Script errors and exceptions are logged to this file. Defaults to the per-user system log file (Max.log)
Dialog Monitor state. When on, the dialog monitor watches for dialogs from plug-ins, and closes them. Valid choices are: 'on|off', 'yes|no', '1|0' and 'true|false'.
Defaults to off.
For more information about the Dialog Monitor, see the "Interface: DialogMonitorOPS" topic in the MAXScript Guide.
MAXScript String Parameter option, where arg = <key>:<value> .
<value> is accessible as a MAXScript string in <script_file> through the maxOps.mxsCmdLineArgs dictionary using <key> as the dictionary key.
The string must be a MAXScript string, meaning it must be enclosed in quotation marks, and any quotation marks or other special characters inside the string must be escaped. The string may be prefixed with an '@' to indicate that it is a verbatim string. See the "String Literals" topic in the MAXScript Guide for more information.
Can be specified multiple times.
MAXScript Value Parameter option, where arg = <key>:<value>.
<value> will be accessible as a MAXScript value in <script_file> through the maxOps.mxsCmdLineArgs dictionary using <key> as the dictionary key.
The <value> parameter must be enclosed in quotation marks.
Can be specified multiple times.
The input 3ds Max scene file to be loaded before <script_file> is executed.
Paths passed as arguments are relative to the current directory, unless fully qualified.
Two command-line options allow you to pass information to the executed MAXScript file, -mxsString and -mxsValue, which pass strings and values respectively. The values are accessible inside MAXScript in the maxOps.mxsCmdLineArgs dictionary as key/value DataPairs.
For example, consider the following command-line invocation:
<3dsmaxpath>3dsmaxbatch demo_mxscmdline.ms -mxsString string1:"Hello" -mxsValue value1:"[3,12,22]" -mxsValue value2:"Point3 3 8 2.3" -listenerLog "test.log"
And demo_mxscmdline.ms script:
opts = maxOps.mxsCmdLineArgs for k in opts.keys do ( format "% == % class: %\n" k opts[k] (classOf opts[k]) )
The listener log test.log will contain the output:
#string1 == Hello class: String #value2 == [3,8,2.3] class: Point3 #value1 == [3,12,22] class: Point3
Python scripts can also access these values through the pymxs.runtime object.
You can also add messages to the log file via MAXScript. Use the logsystem.logEntry <string> broadcast:true function in MAXScript to log script progress. The broadcast:true parameter indicates that 3ds Max should broadcast this log message to 3ds Max Batch.
You can load a 3ds Max scene file as an argument to 3ds Max Batch (-sceneFile) or in your script with loadMaxFile(). The method you choose depends on how you wish to react to missing plug-ins and xrefs. The loadMaxFile() method provides arguments for dealing with missing plug-ins, xrefs, etc, so your script can react accordingly (see the "Quite Mode" topic in the MAXScript Guide). Loading a file via -sceneFile will print missing plug-in and xref information to the console, so the automation script calling 3ds Max Batch can deal with this information.
Exit Codes
Your automation tool can check the exit codes from 3ds Max Batch and 3ds Max to determine whether the job was successful, and if not, what caused the issue. On success, 3ds Max Batch exits with exit code 0. 3ds Max Batch will report these exit codes if there was an error with the parameters passed to it or with communication with 3ds Max:
3ds Max Batch will report a non-zero exit code when 3ds Max logs an error.
In addition, 3ds Max Batch will also report the exit code of 3ds Max if it is not success (0).
MAXScript also allows you exit 3ds Max with a user-defined exit code. To do this, call quitMax with the exicode argument. For example:
quitMAX quiet:true exitCode:-314159
This will print the exit code -314159 to the console: