Book Image

Practical Maya Programming with Python

By : Robert Galanakis
Book Image

Practical Maya Programming with Python

By: Robert Galanakis

Overview of this book

Table of Contents (17 chapters)
Practical Maya Programming with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Writing a skeleton converter library


Let's put composability to work for us. We'll implement a true rite of passage for programming in Maya—a routine to automatically convert a hierarchy of nodes into a hierarchy of joints (a skeleton). This task allows us to focus on building small, composable pieces of code, and string them together so that the character creator tool we build later in the chapter can be very simple. These composable pieces won't just serve our character creator. They'll serve us all throughout the book and our coding lives.

Writing the docstring and pseudocode

Before we start coding, we need a place to put the code. Create the skeletonutils.py file inside the development root you chose in Chapter 1, Introspecting Maya, Python, and PyMEL. This book's examples use C:\mayapybook\pylib.

After creating skeletonutils.py, open it in your IDE. Add the following code. The code defines a function, a docstring that explains precisely what it will do, and pseudocode describing the implementation...