This is an introductory "How to" section for the 3ds Max Python SDK.
The 3ds Max Python API is built on top of and based on the 3ds Max C++ SDK. Global functions, and functions from static interfaces such as the Interface class and the derived classes (Interface7 and so forth), have been regrouped into smaller classes based on functionality, such as: RenderSettings, Animation, Grid, or Snaps. Refactoring was performed for several functionalities in global functions, as well as the core interfaces into the INode class. The goal was to create an API that is more intuitive.
help() and dir() are two of the most useful functions in Python.
For example, you can obtain a list of attributes for a class (list of methods, variables) using help as follows:
import MaxPlus help(MaxPlus.Asset)
To obtain a list of attributes for an object, you can also use the Python built-in dir() function. The dir(object) function, when passed an argument (object), returns a list of attributes for the object.
For more information regarding these two functions, as well as other tips and tricks, see Tips and tricks for 3ds Max Python scripting.
If you execute print statements in your script, the output is printed to the MAXScript Listener window.
A property is an attribute that is the equivalent of a Get() and Set() method pair. You can simply access the attribute to query or set its value.
There exist also read-only properties, which are the equivalent of their corresponding Get() methods.
For example, the ParameterBlock.GetName() method has a corresponding ParameterBlock.Name property.
In the demoApplyMaterial.py example:
m = MaxPlus.Factory.CreateDefaultStdMat() m.Ambient = color m.Diffuse = color
m = MaxPlus.Factory.CreateDefaultStdMat() m.SetAmbient(color) m.SetDiffuse(color)
In the Python API Reference documentation, there are attribute descriptions along the lines of:
tuple Type = _swig_property(GetType)
In this case, Type is a property that you can query to obtain the Type value, and its corresponding method is GetType().
Constants are represented in the Python API along the lines of ColorSelection = _MaxPlus.Colors_ColorSelection as a result of swig.