Notifications
Clear all

[Closed] Executing Python scripts from the command line

Hi guys,
I’m trying to execute my 3dsMax python script from command line.And I don’t want to execute the python script through 3dsmax.exe[*1] since that the print message will all go inside MAXScript Listener instead of showing in the cmd console.

     Now I execute python in cmd console :
               python test.py 

     Inside test.py , I use MaxPlus to open a max file : 
               import MaxPlus
               MaxPlus.FileManager.Open("D:\sceneTest.max")

However ,when I use MaxPlus.FileManger related APIs, it will always appear “Unknown MaxPlus Exception”. Other MaxPlus Apis such as MaxPlus.Application.Get3DSMAXVersion() …etc. work just fine.

Does anyone know what cause the MaxPlus exception and How to solve it ??
Thank you!!!

[*1] http://docs.autodesk.com/3DSMAX/16/ENU/3ds-Max-Python-API-Documentation/index.html?url=files/GUID-8432DD04-7436-4517-9ED1-02E74C814A9A.htm,topicNumber=d30e1994

1 Reply

You can run python only as stated in the docs, there is no “headless” mode as in maya, where you can run python scripts using the “normal” python interpreter. The correct way should be 3dsmax -U PythonHost <your script path>.
For the prints you could do this after importing MaxPlus.


import sys
import MaxPlus
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
MaxPlus.FileManager.Open("D:\sceneTest.max")

Best regards,
Daniel