Maya Python for Games and Film: A Complete Reference for Maya Python and the Maya Python API

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Maya Python for Games and Film is the first book to focus exclusively on how to implement Python with Maya. Written by trusted authorities in the field, this in-depth guide will help you master Maya Python, whether you're a seasoned technical artist looking to make the transition from MEL to Python or an aspiring artist not wanting to scramble for information.

Author(s): Adam Mechtley; Ryan Trowbridge
Edition: 1
Publisher: CRC Press
Year: 2011

Language: English
Pages: 381

1 Maya Command Engine and User Interface
Interacting with Maya
Maya Embedded Language
Python
C++ Application Programming Interface
Python API
Executing Python in Maya
Command Line
Script Editor
Maya Shelf
Maya Commands and the Dependency Graph
Introduction to Python Commands
Flag Arguments and Python Core Object Types
Numbers
Strings
Lists
Tuples
Booleans
Flag = Object Type
Command Modes and Command Arguments
Create Mode
Edit Mode
Query Mode
Python Command Reference
Synopsis
Return Value
Related
Flags
Python Examples
Python Version
Python Online Documentation
Concluding Remarks
2 Python Data Basics
Variables and Data
Variables in MEL
Keywords
Python’s Data Model
Mutability
Reference Counting
del
The None Type
Using Variables with Maya Commands
Capturing Results
getAttr and setAttr
Compound Attributes
connectAttr and disconnectAttr
Working with Numbers
Number Types
Basic Operators
Working with Booleans
Boolean and Bitwise Operators
Working with Sequence Types
Operators
Concatenation
Indexing and Slicing
String Types
Escape Sequences and Multiline Strings
Raw Strings
Unicode Strings
Formatting Strings
More on Lists
del
Nested Lists
Other Container Types
Sets
Operators
Dictionaries
Operators
Dictionaries in Practice
Concluding Remarks
3 Writing Python Programs in Maya
Creating Python Functions
Anatomy of a Function Definition
Function Arguments
Default Arguments
Keyword Arguments
Variable-Length Argument Lists with the * Operator
Variable-Length Keyword Argument Lists with the ** Operator
Return Values
Maya Commands
Listing and Selecting Nodes
The file Command
Adding Attributes
Iteration and Branching
The for Statement
range
Branching
if, elif, and else
Using Comparison Operations
Emulating Switches
continue and break
List Comprehensions
The while Statement
Error Trapping
try, except, raise, and finally
Designing Practical Tools
Concluding Remarks
4 Modules
What Is a Module?
Modules and Scope
Module Encapsulation and Attributes
The __main__ Module
Creating a Module
The spike Module
Default Attributes and help
Packages
create.py
math.py
__init__.py
Importing Modules
import versus reload
The as Keyword
The from Keyword
Attribute Naming Conventions and the from Keyword
Python Path
sys.path
Temporarily Adding a Path
userSetup Scripts
userSetup.py
userSetup.mel
sitecustomize Module
sitecustomize.py
Setting Up a PYTHONPATH Environment Variable
Maya-Specific Environment Variables with Maya.env
Systemwide Environment Variables and Advanced Setups
Windows
OS X
Using a Python IDE
Downloading an IDE
Wing IDE
Eclipse
Basic IDE Configuration
Views
Selecting an Interpreter
Automatic Code Completion
Projects
Connecting to Maya
Debugging
Concluding Remarks
5 Object-Oriented Programming in Maya
Object-Oriented versus Procedural Programming
Basics of Class Implementation in Python
Instantiation
Attributes
Data Attributes
Methods
__str__
__repr__
Properties
Class Attributes
Static Methods and Class Methods
Human Class
Inheritance
Procedural versus Object-Oriented Programming in Maya
Installing PyMEL
Introduction to PyMEL
PyNodes
PyMEL Features
Advantages and Disadvantages
A PyMEL Example
Concluding Remarks
6 Principles of Maya Tool Design
Tips When Designing for Users
Communication and Observation
Ready, Set, Plan!
Simplify and Educate
Tools in Maya
Selection
Marking Menus
Options Windows
Concluding Remarks
7 Basic Tools with Maya Commands
Maya Commands and the Maya GUI
Basic GUI Commands
Windows
Building a Base Window Class
Menus and Menu Items
Executing Commands with GUI Objects
Passing a Function Pointer
Passing a String
Using the functools Module
Layouts and Controls
Basic Layouts and Buttons
Form Layouts
Complete AR_OptionsWindow Class
Extending GUI Classes
Radio Button Groups
Frame Layouts and Float Field Groups
Color Pickers
Creating More Advanced Tools
Pose Manager Window
Separating Form and Function
Serializing Data with the cPickle Module
Working with File Dialogs
Concluding Remarks
8 Advanced Graphical User Interfaces with Qt
Qt and Maya
Docking Windows
Installing Qt Tools
The Qt SDK
Qt Designer
Widgets
Signals and Slots
Qt Designer Hands On
Loading a Qt GUI in Maya
The loadUI command
Accessing Values on Controls
Mapping Widgets with Signals and Slots
PyQt
Installing PyQt
Using PyQt in Maya 2011+
Using PyQt in Earlier Versions of Maya
Concluding Remarks
9 Understanding C++ and the API Documentation
Advanced Topics in Object-Oriented Programming
Inheritance
Virtual Functions and Polymorphism
Structure of the Maya API
Introducing Maya’s Core Object Class: MObject
Manipulating MObjects Using Function Sets
How Python Communicates with the Maya API
How to Read the API Documentation
Key Differences between the Python and C++ APIs
MString and MStringArray
MStatus
Void* Pointers
Proxy Classes and Object Ownership
Commands with Arguments
Undo
MScriptUtil
Concluding Remarks
10 Programming a Command
Loading Scripted Plug-ins
Anatomy of a Scripted Command
OpenMayaMPx Module
Command Class Definition
doIt
Command Creator
Initialization and Uninitialization
Adding Custom Syntax
Mapping Rotation Orders
Class Definition
Syntax Creator
Flag Arguments
Command Objects
Initialization of Syntax
doIt
Object Validation
Storing Flag Arguments
doItQuery
Maya’s Undo/Redo Mechanism
Supporting Multiple Command Modes and Undo/Redo
Undo and Redo
MDGModifier
Command Modes
Syntax Creator
__init__
Initializing for isUndoable
Other Data Attributes
doIt
Object Validation
Selecting Query Mode
Selecting Edit or Create Mode
redoIt
Creating New Nodes
Editing the Transform Node
undoIt
Concluding Remarks
11 Data Flow in Maya
Dependency Graph
Dependency Nodes
Attributes
Plugs
Data Blocks
compute
Data Handles
Attributes and Data Flow
Connections
Lazy Evaluation and Push–Pull
Triggering DG Evaluation
Debugging the Dependency Graph
Heat Map Display
The dgTimer Command
Directed Acyclic Graph
DAG Paths and Instancing
The Underworld
Concluding Remarks
12 Programming a Dependency Node
Anatomy of a Scripted Node
The ar_averageDoubles Node
Node Class Definition
Node Creator
Node Initializer
compute
Best Practices
Initialization and Uninitialization
Attributes and Plugs
Attribute Properties
Readable, Writable, and Connectable
Storable Attributes and Default Values
Cached Attributes
Working with Arrays
Logical and Physical Indices
Implementing Plug Arrays
Implementing Array Plugs
Compound Attributes
Concluding Remarks
Maya Python for Games and Film: A Complete Reference for Maya Python and the Maya Python API
Copyright
Acknowledgments
Introduction: Welcome to Maya Python
Python versus MEL
Companion Web Site
Notes on Code Examples and Syntax
Whitespace
Line Breaks
Our Approach
Quotation Marks
Comments
Python Hands On
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W