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

Get Practical Maya Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.