This release of 3ds Max introduces several changes and improvements to the Max Python API.
The version of Python that ships with 3ds Max is now 2.7.6.
The Python interpreter is located in the 3ds Max install directory, and is named 3dsmaxpy.exe. This is provided to allow external execution, for example to provide integration with package management with PIP. Note: PIP is not included with Python 2.7.6, but you can install it. See the "Python extension libraries" topic for more information.
The MaxScript editor now has Python language support, including syntax highlighting, auto-completion, and the ability to execute Python scripts from the editor. This simplifies writing and executing Python, which no longer has to be passed as a string or file to Python.Execute() or Python.ExecuteFile() via MaxScript.
The MaxScript editor now supports "split" view - with two scripts side-by-side. To enable this feature, drag the tab of an open document and select "Clone to another view" or "Move to another view".
The listener now supports a Python command line, including the ability to enter multi-line blocks of code. The buffer is executed by entering Ctrl+Enter. Enter Python mode by either selecting the Python radio button, or entering\>>\> and a space on the MaxScript command line.
Python libraries can now be "imported" into MaxScript scripts using Python.import(). Modules can be re-loaded using Python.reload().
See "Using Python Libraries in MAXScript" for more information.
The full MAXScript runtime is now available to Python scripts via the new pymxs.runtime module. This module exposes all the global symbols of MAXScript.
The MAXScript context expressions animate, at time, at level, quiet, and redraw are available in pymxs. This module also exposes the MAXScript undo/redo and runundo/runredo commands. It provides a mechanism to call pymxs.runtime commands from a worker thread with pymxs.mxstoken.
See pymxs API Introduction for more information.
All PySide libraries are now included in the 3ds Max Python distribution, instead of just a sub-set, and the PySide version is upgraded to 1.2.2, QtCore version 4.8.5.
You can now properly parent a PySide widget to the 3ds Max main window by using MaxPlus.AttachQWidgetToMax(). (Introduced in the 3ds Max 2016 Ext 1 release).
Note: The preferred method for parenting to the 3ds Max main window is to use MaxPlus.GetQMaxWindow(), as discussed above.
The pysideuic module is now pre-installed, so that Qt Designer UI files may be easily loaded at runtime. See "Loading Qt UI Files" below.
MaxPlus now directly exposes the 3ds Max main window as a QWinWidget, with MaxPlus.GetQMaxWindow(). Here is an example of using this API to set the main window as the widget parent:
w = QtGui.QWidget() w.setParent(MaxPlus.GetQMaxWindow()) # by default the QWidget is modeless
For a modal dialog, use this approach:
w = QtGui.QWidget() w.setParent(MaxPlus.GetQMaxWindow()) w.exec_() # display modal
You can now dock Qt widgets to the 3ds Max UI, using MaxPlus.MakeQWidgetDockable(w, pos_flag).
The pos_flag argument is a bit flag:
You can OR or add values to combine them.
For example:
import MaxPlus from PySide.QtGui import * w = QWidget() MaxPlus.MakeQWidgetDockable(w, 14), #Make dockable on Left, Right and Bottom
The pysideuic module is now pre-installed, and MaxPlus now includes a facility for loading UI files created by Qt Designer at runtime, MaxPlus.LoadUiType():
uitype, basetype = MaxPlus.LoadUiType(uifile)
For example:
import pysideuic from PySide import QtCore, QtGui fname = "scripts/python/example.ui" formt, btype = MaxPlus.LoadUiType(fname) class TestWidget(btype, formt): def __init__(self, parent=None): btype.__init__(self) formt.__init__(self) self.setupUi(self) form = TestWidget() form.show()
The AppData Chunk API has been exposed in MaxPlus. See the demoAppChunk.py sample script for an illustration of how to use this API.
The Quad Poly API has been exposed in MaxPlus. See the demoPolyObject.py sample script for an illustration of how to use this API.
SplineShape.UpdateShape() has been added to update a spline in the 3ds Max scene. This is similar to the MAXScript UpdateShape function.