Due to a miscommunication between Elsevier Press and the Python Software Foundation, the first printing of this title used an unauthorized modification of the trademarked Python logo. We apologize to the PSF for this, and they have been understanding of our in-press status; in the 2nd and subsequent printing of this title, we shall use a cover design that has been approved as non-dilutive by the Python Software Foundation.

Help make the world a better place and make a secure donation to the Python Software Foundation today!



Welcome to Maya Python


Ryan Trowbridge


Contrast a MEL and a Python API version of a vertex noise script

Example Files



This introductory chapter explains what the book is about and aims to excite readers about the possibilities Python affords them in Maya. We provide a MEL version and a Python API version of a script, which adds vertex noise to a dense mesh, to show a quick example of some of the dramatic performance boosts readers will learn how to harness. Fundamentally, this chapter highlights what readers can expect to learn and why Python is so cool!



Other Notes


Errata for the First Edition

On p. xviii in the section on Line Breaks, the first MEL example has an errant closed parenthesis at the end of the third line.

4 Responses to “Introduction”

  1. Dear Ryan,

    I’m an aspiring technical artist in animation, and I was recommended your book as a good launching point for Python in Maya. I got to the first exercise in the book about loading scripts, and I ran into an issue.

    When I got to execute the polyNoise.py script in Maya I get this error:

    # Error: NameError: name ‘time’ is not defined

    I don’t really understand scripting yet to attempt to fix that problem…so any help would be appreciated.


    Teresa Leong

  2. P.S I am using Maya 2012

    What version of python am i learning?

  3. Hi Teresa,

    If you execute the following code, you can see that Maya 2012 uses Python 2.6.4:

    import sys
    print sys.version

    As for your other question, the script certainly should work. Make sure its entire contents are displayed in the Input Panel. Specifically, ensure that the third line is:

    import random, time

  4. If anyone can’t find the Python tab as mentioned in the text, right click and hold on the MEL tab (in the script editor) and click on create tab. You’ll get a Python option, and when you take it, it will give you the Python tab. For single lines, the bottom script editor is toggled between MEL and PYTHON by left clicking the tab. I have no clue how to get to C++. Previous student versions of Maya didn’t include Python, but 2012 does if you use the above add tab to get there. If you can’t download the text above, double left click it, click copy, then you can click paste in the bottom Python window. After that, click control>enter to move it to the top window, and run the “play” button to get the author’s cool dead planet in your perspective window.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.