Introduction
Welcome to Maya Python
Author
Ryan Trowbridge
Project
Contrast a MEL and a Python API version of a vertex noise script
Example Files
Synopsis
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!
Resources
None
Other Notes
None
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.
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.
Thanks!
Teresa Leong
Teresa said this on October 14, 2011 at 8:05 am |
P.S I am using Maya 2012
What version of python am i learning?
Teresa said this on October 14, 2011 at 8:10 am |
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
Adam said this on October 14, 2011 at 9:34 am |
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.
Tom Halstead said this on July 14, 2012 at 2:49 pm |