Learning the Maya Python API by example

Something like the Maya API is best explained through demonstration. Once you get the hang of it, the Maya API Reference and its copious examples will be a wonderful source of information. However, it will take some time and effort to become proficient. This section will present several easy-to-tackle problems to help illustrate the Maya Python API.

Converting a name to an MObject node

It's important to remember that when we step into the world of OpenMaya, we leave the Pythonic simplicity of PyMEL behind. The following line of code converts a node name string into a PyMEL PyNode:

>>> pmc.PyNode('mynode')
nt.Transform(u'mynode')

In the wonderful world of the Maya Python API, though, there is much more code involved ...

Get Practical Maya Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.