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...