Results 1 to 10 of 10

Thread: non-alphabetical characters in 3ds Max command line rendering

  1. #1
    undefined
    Join Date
    Feb 2017
    Posts
    7

    Default non-alphabetical characters in 3ds Max command line rendering



    Hello,
    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:

    Code:
    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?

    Thanks

  2. #2
    Administrator Jeff Hanna's Avatar
    Join Date
    Jul 2008
    Location
    Champaign, IL
    Posts
    128

    Default

    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.
    Jeff Hanna
    Principal Technical Artist
    Volition

  3. #3
    undefined
    Join Date
    Feb 2017
    Posts
    7

    Default

    Quote Originally Posted by Jeff Hanna View Post
    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.

  4. #4
    isKindOf Artist
    Join Date
    Dec 2009
    Location
    Czech republic
    Posts
    31

    Default

    What about enclosing the path in quotes?

  5. #5
    undefined
    Join Date
    Feb 2017
    Posts
    7

    Default

    Quote Originally Posted by Swordslayer View Post
    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:\test(1)\tmp.max\".

  6. #6

    Default

    from python just don't add quotes. simple "D:/test(1)/tmp.max" (or, better, "D:\\test(1)\\tmp.max") should work for subprocess.Popen.

  7. #7
    /?
    Join Date
    Aug 2008
    Location
    Atlanta, GA
    Posts
    153

    Default

    Quote Originally Posted by uiron View Post
    from python just don't add quotes. simple "D:/test(1)/tmp.max" (or, better, "D:\\test(1)\\tmp.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). : )
    Eric N. Evans
    Sr. Technical Artist
    Hi-Rez Studios
    http://www.ericnevans.com

  8. #8
    undefined
    Join Date
    Feb 2017
    Posts
    7

    Default

    Quote Originally Posted by uiron View Post
    from python just don't add quotes. simple "D:/test(1)/tmp.max" (or, better, "D:\\test(1)\\tmp.max") should work for subprocess.Popen.

    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.

  9. #9
    variable
    Join Date
    Jun 2013
    Location
    Kaunas, Lithuania
    Posts
    29

    Default

    Could it be an issue with encodings? Is there a difference if you do it like this:
    Code:
    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?:
    Code:
    popenArgs = ["D:/printArg1.bat", "D:/tmp(.max"]
    printArg1.bat:
    Code:
    echo %1 >> D:\tmp.txt

  10. #10
    undefined
    Join Date
    Feb 2017
    Posts
    7

    Default

    Quote Originally Posted by Zhalktis View Post
    Could it be an issue with encodings?
    I tried to encode the path in sys.getfilesystemencoding(), utf-8 and utf-16 but none of them fixes the issue.

    Quote Originally Posted by Zhalktis View Post
    Could you check if python mangles the name by calling a simple .bat file instead of 3dsmaxcmd.exe?[/code]

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •