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

Building the node factory


In the following sections, we will implement the concepts explained in Designing the node factory. This will involve moving incrementally from the traditional circle node plugin we built in Understanding Dependency Graph plugins, first extracting out some of the duplication to use attribute specifications, then tying in the node specification, and finally overriding the compute method.

Specifying attributes

The first step in building the node factory is to create the attribute specification base class and the concrete subclass we will need for float attributes. Create a file at C:\mayapybook\pylib\nodefactory.py and type into it the following code:

from maya import OpenMaya, OpenMayaMPx

class AttrSpec(object): #(1)
    def createfnattr(self):
        raise NotImplementedError()
    def getvalue(self, datahandle):
        raise NotImplementedError()
    def setvalue(self, datahandle, value):
        raise NotImplementedError()
    def create(self, fnattr, longname...