Maya Python API

The Python API allows a much more palatable platform from which to author fast-running code within Maya. The C++ API still rules the roost when it comes to speed, but this requires not only knowledge of C++, but also the use of Visual Studio. To top that, each time you change a C++ plugin, it needs to be unloaded, the code needs to be recompiled and the plug-in reloaded. This can hinder iteration times massively, especially if you’re tinkering to experiment with an algorithm.

Speed Comparisons:

In the tests below, we implement three different version of the same algorithm: calculate the area of a sphere with 90,000 faces, by iterating over each face.

Maya Python: 20.96 seconds

PyMel: 16.61 seconds

Python API: 0.15 seconds

In this test, the API is 140x faster than native Maya Python, and 110x faster than PyMel!

Code Used:

Maya Python:

Pymel:

Python API:

 Previous: Pymel Code Snippets