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

Extending the node factory


The following sections cover extending the node factory's functionality. We will add support for string, color, and enum attributes, transform nodes, and overriding MPxNode methods other than compute.

There are many more features to support than what's covered here, such as string and array attributes. When it comes time to add a new feature to the node factory, I suggest you start by getting comfortable with its implementation using the Maya Python API directly. Only then should you support it in the node factory. This is due, first and foremost, to the fact that many examples and tutorials exist for the API. Second, it is due to the fact that diagnosing issues in the node factory can be difficult due to its dynamism.

Supporting string and color attributes

Adding support for string and color attributes demonstrates the power of the attribute specification design. For string attributes, add the following code to nodefactory.py:

class _StringAttr(AttrSpec):	
    def...