Executing Python from MAXScript

Executing Python from MAXScript

You can execute Python commands and statements (can be a single command/expression or a series of statements); or a Python script (for example, a .py script) from within MAXScript. Use the python.Execute and python.ExecuteFile commands respectively, as follows:

python.Execute "print 'hello'"
python.ExecuteFile "demoBentCylinder.py"

If you provide a full path using the ExecuteFile command; for example, as follows; 3ds Max looks for the Python file in the path provided.

python.ExecuteFile "C:\Program Files\Autodesk\3ds Max 2015\scripts\Python\demoBentCylinder.py"

Otherwise, 3ds Max looks for the Python script under the following directories:

For example, 3ds Max would search under the following directories: userscripts\python, userscripts\startup\python, scripts\python, scripts\startup\python, and subsequently the windows paths.

The output of the results from scripts are printed to the MAXScript Listener window.

Python interface methods

If you run

showinterface python

in MAXScript, you obtain, in the MAXScript Listener, a list of available methods. The following list describes these methods and arguments: