pythoncommand-line-interface3dsmaxmaxscript

3DsMax Run python script from CLI with arguments


I have written a script in Python to automate some tasks in 3DsMax 2018. The script takes 2 parameters / arguments to work as needed. More specifically the name of the input and output path.

I run the script from CLI with the following command and everything works fine:

3dsmax.exe -U PythonHost C:Users\user\Desktop\Script.py

But when I pass arguments, they are not recognized by the script / 3DsMax:

3dsmax.exe -U PythonHost C:Users\user\Desktop\Script.py test

I checked the incoming arguments with print(sys.argv), but only the path to the python script is listed as an argument. Is there a way of passing arguments to the cli?


Solution

  • I figured it out myself, if anyone else has this problem, here is what I found out. To add parameters of any kind you have to use the 3dsmaxbatch.exe.

    My example would look like this:

    3dsmaxbatch.exe C:Users\user\Desktop\Script.py -mxsString string1:"test"
    

    The documentation of 3dsMaxbatch was very helpful to find out the possible cli options.

    https://knowledge.autodesk.com/support/3ds-max/learn-explore/caas/CloudHelp/cloudhelp/2019/ENU/3DSMax-Batch/files/GUID-48A78515-C24B-4E46-AC5F-884FBCF40D59-htm.html