The PyMEL project makes Python scripting with Maya work the way it should. Maya's command module is a direct translation of mel commands into python commands. The result is a very awkward and unpythonic syntax which does not take advantage of python's strengths -- particulary, a flexible, object-oriented design. PyMEL builds on the cmds module by organizing many of its commands into a class hierarchy, and by customizing them to operate in a more succinct and intuitive way.
For those who are already masters of python and who naturally expect more out of a python package, PyMEL is for you, too. It was written in for use in production by experiened programmers with a vision for how to add object-oriented design to Maya.
Powerful Classes
Node classes for every node type
camTrans, cam = camera() # create a new camera
cam.setFocalLength(100)
fov = cam.getHorizontalFieldOfView()
cam.dolly( -3 )
cam.track(left=10)
cam.addBookmark('new')
An Attribute class organizes all the attribute commands in one place
s = polySphere()[0]
if s.visibility.isKeyable() and not s.visibility.isLocked():
s.visibility.set( True )
s.visibility.lock()
print s.visibility.type()
Manipulate file paths with ease
#backup all mb files in the current scene's directory
basedir = sceneName().parent
backupDir = basedir / "backup" #slash op joins paths
if not backupDir.exists:
backupDir.mkdir()
for file in basedir.files( '*.mb' ):
print "backing up: ", file.name
file.copy( backupDir / (file.namebase + ".old") )
Work with shape components, perform vector math, and easily set object attributes with the results
#select all faces that point up in world space
s = polySphere()[0]
for face in s.faces:
if face.getNormal('world').y > 0.0:
select( face, add=1)
Manage optionVars as a python dictionary
if 'numbers' not in optionVar:
optionVar['numbers'] = [1,24,47]
optionVar['numbers'].append(9)
numArray = optionVar.pop('numbers')
PyMEL provides customized operators for succinct scripting:
cam = camera()[0]
sphere = polySphere()[0]
sphere | cam # parent the camera to the sphere
cam.tx >> cam.ty # connect operator
cam.tx // cam.ty # disconnect operator
Includes Tools to Ease Your Transition to Python
* mel-to-python translator for converting mel script into python scripts
* python-to-mel plugin factory for turning python classes into mel commands
* ipymel customized python interpreter
NOTE: Pymel is a cross-platform tool available for Linux, Windows and Mac OS X.
Product's homepage
Requirements:
· Python
What's New in This Release: [ read full changelog ]
Changes:
· rolled back ``listConnections()`` change from 1.0.1
· commands wrapped to return PyNodes
· - ``container()``
Additions:
· added functions for converting strings to PyQt objects: ``toQtObject()``, ``toQtLayout()``, ``toQtControl()``, ``toQtMenuItem()``, ``toQtWindow()``
· added method for converting PyMEL UI objects to PyQt objects: ``UI.asQtObject()``
Bugfixes:
· fixed a bug where ``nt.Conditions()`` created a script condition