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 character creator


So far, we've written the code to convert a hierarchy of transforms into joints. Now we must write something that we can hook up to a menu and a workflow. An overly simplified solution is to convert the current selection by assigning the following expression into a shelf button:

map(skeletonutils.convert_to_skeleton, pmc.selection())

But that's a pretty bad high-level function. What about error handling, user feedback, and the high-level decisions that we put off while writing the converter?

What we really want is something like the following:

charcreator.convert_hierarchies_main()

This can be hooked up to a menu button, which provides a better experience for the user and a place to make those decisions that we kept out of the skeletonutils module.

Stubbing out the character creator

Create a charcreator.py file next to the skeletonutils.py file in your development root, and open it up in your favorite IDE. Go ahead and type the following code, which will stub out the...