The Maya Python API 2.0 is a new version of the Maya Python API which provides a more Pythonic workflow and improved performance. Both the new and old APIs can co-exist in the same script but objects from the two different APIs cannot be used interchangeably.
The Python API 2.0 has a number of advantages over the original API:
array.sizeIncrement=64
.The new Python API modules are found in maya.api.
For example:
Module names are the same as in the old API with the exception that the proxy classes (i.e. those beginning with MPx) no longer have their own module but reside in the same modules as other related classes. This more closely resembles the C++ API.
Class names are the same as in the old Python API and the C++ API. Method names are mostly the same with some differences where it affects the workflow. Some methods which simply get or set values on an object have been replaced with Python object attributes.
New and old API classes can be used within the same script, but their objects are not interchangeable. Thus, you can do this:
but not this:
Given that the class and method names are mostly identical between the two APIs there is a lot of potential for confusion so it's best not to mix them if you can avoid it.
When writing a plugin that uses the new API, the plugin must define a variable called maya_useNewAPI
so that Maya will know to pass it objects from the new API rather than the old one. For example,
We encourage users to provide feedback on this new Python API through the online Suggestion site available from the Maya Help Menu and through the Autodesk Developer Network.