PyMEL Python Module for Maya

March 31st, 2009

If Maya is the giant killer robot, the Maya interface is the control panel in the underground bunker, miles from the action. The interface is a limited set of tools, but when you push the buttons on the panel, mushroom clouds form on the horizon, and for most people that’s good enough.

If you really want to get your hands dirty with Maya, and feel the rush of punching through buildings yourself, you’re going to have to learn to code. Maya gives you a few options for getting that buzz, but the most promising thing I’ve found so far is a third-party open-source project called PyMEL. But first, a strained metaphor for my artist homeboys.

The Ghosts in the Machine

A mushroom cloud

If you use Maya’s interface for very long, you start to notice relationships between the buttons you push and the motion of the gears and levers visible through the portholes in the control panel. Eventually you might be brave enough to start pulling pieces of the panel off to get at the guts. Inside you’d find a Rube Goldberg device of gears and rubber bands, maintained by dancing Keebler elves. This is MEL, the Maya Embedded Language, a scripting language with which the whole Maya interface is built.

This elvish mechanism communicates with the giant robot, and compels it to do your bidding. The robot itself is powered by magic, and certain wizards can control it directly, but if you don’t want to risk your very sanity learning magic you can still do a lot with the elves. In fact, if you were so inclined, you could use MEL to rewrite the entire interface, limited of course by your capacity to convince elves to do things with gears and rubber bands.

Most people who get into MEL are happy enough to stay at the button-twiddling level, and Maya certainly makes it easy. There’s a script editor built right into the GUI, and you can watch the elves do their gear dances as you push the buttons and move things around. There’s a feeling of power, and you can impress your enemies. Also, there are mushroom clouds.

Spooky Action at a Distance

However, should you desire more or larger mushroom clouds, you will run into the limits of elf technology. Like any scripting language, MEL facilitates interactions with the application in question, but it’s not a true programming language. It’s good for automating button-pushing and other GUI-related tasks, but try anything tricky and the elves get confused.

Ernie the Keebler Elf
Not a genius

Since Maya 8.5, released in 2007, Maya has included a Python “wrapper” for the MEL code, which is a bit like including Einstein with an Erector Set. Einstein is much, much better at solving problems in his head than elves, but there’s still only so much he can do with gears and rubber bands. This is frustrating, because Python is a flexible and powerful language, with an object-orientedness particularly suited to my metaphor-oriented mind, but it’s hamstrung by its role as a MEL babysitter.

So. We’re left with gimpy Einstein hanging around in our underground lab, picking elves out of his teeth as he struggles to control a killer robot with a long-distance Erector Set. As it happens, Einstein also knows magic, but if you knew magic, you wouldn’t need Einstein or his Erector Set in the first place. What to do?

Einstein at the Controls

PyMEL is an open-source Python module developed by the folks at Luma Pictures, a film vfx studio in Venice, CA. PyMEL replaces Maya’s Python implementation with a re-organization of Maya’s Python API into a class hierarchy intended for scripters. In artist language, this means it’s a whole new control panel tuned for Einstein, skipping the MEL elves and their Erector Set entirely, and enabling vastly more efficient Einstein-to-robot communication. However, it still plays nice with the elves, including a MEL-to-Python translator.

It’s very much a work in progress, and there are holes in the machine, but from what I’ve seen so far it feels like a can opener to Maya’s often-tight lid. In this illuminating youtube video the PyMEL project lead asks that Maya users pester Autodesk to include a Python interpreter in future versions of Maya’s GUI. This would begin to break down the difference between scripting and coding for Maya, putting Einstein directly into the giant killer robot’s head and allowing him to apply his amazing brainpower more efficiently to the creation of large explosions of productivity.

Now all I need to do is learn German. Stay tuned.

« previously: Fake reel update | Home | next: Random walk keyframed blocks in Python »

Leave a Reply