Sunday, August 8, 2010

Getting Started

Lets get started with an into to scripting in Maya. 
Start off by opening the script editor: Windows > General > Script Editor
You should also always have the API open at the same time:  In the Maya Docs go to Technical Documentation > CommandsPython.  Now, if your new to scripting by thankful your starting off in Maya.  The documentation and interpreter feedback are the best in the business.  90% of Maya's commands are echoed after execution and the API is extremely well documented.  All the commands have examples, and are both searchable and categorized. Luckily, Maya Scripting IS NOT a two bit chapter in a thousand page pdf manual, more on those programs later.

You could start off in MEL.  There are plenty of advantages in doing so:
  • No need to import commands
  • Automatic sourcing
  • Maya's feedback is all in MEL 
  • Unicode support
  • Maya ASCII is all in MEL
  • Expressions, Render Options, and many nodes except MEL directly
However, whenever possible I will be making my scripts in Python.
  • Extremely expandable using modules.  NumPy, Django,...
  • Extensive UI development.  wxPython, PyQT
  • Compatible with many other CG applications.  Nuke, Houdini, Realflow, XSI, ...
  • Syntax highlighting/decoration.
  • Object Oriented.
  • Easily readable.  NO ; $ ` required.
 In either the MEL or Python tab type:
print "Hello World" 
>>Hello World
To execute your code it is best to highlight the portion you want to run, then hit Control+Enter.  Maya's interpreter will return Hello World and you have completed your first script.