Non-alphabetical characters in 3ds Max command line rendering



i’m trying to render scenes with non-alphabetical characters in their names through the python subprocess module, but i get a syntax error from the 3dsmaxcmd.exe.

This is an example, which i want to get working:

import subprocess

popenArgs = ["C:\\Program Files\\Autodesk\\3ds Max 2017\\3dsmaxcmd.exe", "D:/tmp(.max"]
maxProc = subprocess.Popen(popenArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdoutdata, stderrdata = maxProc.communicate()
print stdoutdata.decode('utf-16')

This prints “Syntax Error: (” and a list of all available commands for the 3dsmaxcmd.exe.
Starting the rendering directly from the command line works fine and rendering D:/tmp.max with the python script works also.

Does someone have an idea what i am missing, when i have special characters like “&” or “(” in the scene path?



Can you capture one of the full path strings and post it, please? My first guess is that the special characters are not being escaped correctly, therefore being interpreted incorrectly.


What do you mean by “capturing the full path string” ? In my example the full path to the scene is “D:/tmp(.max” .
“D:/test(1)/tmp.max” has the same issue, while “D:/test/tmp.max” is working.


What about enclosing the path in quotes?


In the command line it works with and without quotes around the scenepath, but in the python script it doesn’t.

When using quotes in the script: ““D:/test(1)/tmp.max”” the subprocess returns: Error opening scene file: “D: est(1) mp.max”.


from python just don’t add quotes. simple “D:/test(1)/tmp.max” (or, better, “D:\ est(1)\ mp.max”) should work for subprocess.Popen.


Not to distract from the thread’s core subject too much, but why is “\” prefered over “/” in this case. I ask because I’m currently standardizing the handling of paths in MAXScript at my studio. At the moment, we’re leaning toward the “/” character method of dividing directories because that approach makes for the shortests path, is Perforce friendly (and is, subjectively, more “elegant” than either the “\” or the “@” character for verbatim strings approaches). All of that said, I’d love to hear what you all have to say on the subject (and now would be a great time for us to change things up). : )


In this case subprocess.popen has no problem with or without the additional quotes. The syntax error i got is not from the python script, but it is returned from the 3dsmaxcmd.exe and stored in my stdoutdata variable.
For some reason the 3dsmaxcmd.exe can’t handle the argument given by subprocess.popen. So there must be a difference between typing a command directly in the command line and using subprocess.popen.


Could it be an issue with encodings? Is there a difference if you do it like this:

popenArgs = ["C:\\Program Files\\Autodesk\\3ds Max 2017\\3dsmaxcmd.exe", "D:/tmp(.max".encode(sys.getfilesystemencoding())]

Could you check if python mangles the name by calling a simple .bat file instead of 3dsmaxcmd.exe?:

popenArgs = ["D:/printArg1.bat", "D:/tmp(.max"]


echo %1 >> D:	mp.txt


I tried to encode the path in sys.getfilesystemencoding(), utf-8 and utf-16 but none of them fixes the issue.

When using [“D:/printArg1.bat”, “D:/test(/tmp.max”] as popenArgs, the .bat file echos: D:/test(/tmp.max , so there is no problem.