PyMaya and PyMel - Embedded Python Interpreter in Maya (c) 2004

PyMaya and PyMel are plugins that embed the Python interpreter into Maya. Data types have been mapped allowing for seamless integration between the two and providing a viable alternative to the existing embedded language, MEL

SourceForge Project Page

Remko Noteboom <remkon@users.sourceforge.net>

From README -----------


PyMaya and PyMel are plugins that embed the Python interpreter into Maya.

Alias Maya is a premier 3D modeling, animation, effects and render solution.
It is a standard software package used in the Film, TV and Video Game
industries for high end 3D Computer Graphics.
Maya embeds its own programming language, MEL (Maya Embedded Language),
but it is very limited in its capabilities as a programming language.

Python is an interpreted, interactive, object-oriented programming language.
Python combines remarkable power with very clear syntax. It has modules,
classes, exceptions, very high level dynamic data types, and dynamic typing.
It is a widely used and widely accepted programming language that has
a large number of extensions.




It consists of two parts: PyMaya and PyMel

1) PyMaya is a plugin for Maya which embeds the python interpreter.
2) PyMel is an extension to python which allows you to execute MEL (Maya
Embedded Language) through the python language.

Both can be used independantly of each other but, when used together, provide
effective two way communication between Maya and Python,  These
two plugins allow the replacement of MEL as a programming language
and use the power, flexibility and scalability of the Python language
within the Maya environment.  All python modules can be used in conjunction
with the MEL command language. 


PyMaya
------
PyMaya embeds the python interpreter into maya.  The interpreter is
persistant during the entire time that the plugin is loaded.

From the command prompt in Maya, you can type:

python foo.py

This will execute the python script in the interpreter running within Maya.



PyMel
-----
PyMel is a Python extension which allow a Python program to execute
MEL commands.  Any command from the MEL command may be executed.  Many
of the MEL datatypes have been mapped back to Python so MEL commands
will return back proper Python datatypes.

Example
-------
from pymel import *
(tx, ty, tz) = mel("xform -q -translate")


PyMel can be run as standalone or within Maya.  As a standalone,
the maya universe must be initialize at the beginning and finalized
at the end.  The is a requirement for all standalone programs that
access Maya.

Example
-------

# import mel commands
from pymel import *

# initialize the maya universe
maya_init()

# create a sphere and print the output
print mel("sphere")

# translate the sphere to a different set of coordinates
mel("xform -t 45 12 14")
print "xtrans: ", xtrans
print "ytrans: ", ytrans
print "ztrans: ", ztrans

# end maya universe
maya_cleanup()


SourceForge.net Logo