Using 3ds Max Batch

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.

To start using 3ds Max Batch, do the following:
  1. Open a command prompt window.
  2. Change directory to the location where 3ds Max is installed. The default is C:\Program Files\Autodesk\3ds Max <version#>.
  3. Enter the following:

    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.

  4. 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.

3ds Max Batch Options

You can pass one or more of the following as options to 3dsmaxbatch.exe.

-help
Show all options.
-v arg

System log verbosity level. Valid arguments are:

  • 0 - fatal errors
  • 1 - errors
  • 2 - warnings
  • 3 - process information messages
  • 4 - all informational messages
  • 5 - debug level messages.

The default is 2.

Note: This parameter only affects messages generated by 3ds Max Batch, not 3ds Max itself. For example, a setting of 5 will not display all messages generated by 3ds Max. See the section below.
-dateFormat arg

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.

-timeFormat arg

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.

-i arg

The 3ds Max config file (.ini). Defaults to the per-user default config file (3dsmax.ini).

-p arg

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

-listenerlog arg

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.

-log arg

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)

-dm arg

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.

-mxsString arg

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.

-mxsValue arg

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.

-sceneFile arg

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.

Passing information to the 3ds Max Batch Script

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.

Getting Information About Your 3ds Max Batch Job

To find and fix errors in batch processing scripts, you can first run the script in 3ds Max. Once the script is working correctly, you can run it in 3ds Max Batch. There are two main logs that provide useful information when running scripts:
  • The MAXScript Listener Log captures your commands and all printed output in a text file. By default, 3dsmaxbatch does not create a listener log, but you can specify one by specifying the -listenerlog option.
  • The 3ds Max Session Log captures your session to %LOCALAPPDATA%3dsMax\<version#>-64bit\<lang>\network\Max.log by default. You can change the file path using the -log command line option. MAXScript and Python script errors are logged to this file
Note: We recommend you always turn on the Listener Log to benefit from the script execution output for information and debugging purposes.

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: