There are certain basic elements that depency nodes share. These include implementing core functions, declaring attributes, and handling data.
All dependency node plug-ins need to use the following classes.
Class | Purpose |
---|---|
MFnPlugin | Maya plug-in function set. This is always required when creating a plug-in |
MPxNode | The base dependency node proxy class. Proxy classes for specific node types that derive from MPxNode are also included in the API. All dependency node plug-ins must extend a node proxy class. |
MTypeID | Used to register the type ID of the dependency node. All dependency nodes must have a type ID. If your node will only ever be used internally to your organization, you can use any value from 0 to 0x7ffff. However, if you intend to distribute your node, you will need to register a node ID range from http://mayaid.autodesk.io/. |
MPlug | Uniquely identifies and references a point of connection defined by a specific node-attribute pair. |
MDataBlock | Wrapper class for data blocks. A data block stores all of a node's data. All attribute data for a node is stored in the node's data block. |
MDataHandle | Wrapper class for data handles. A data handle points to the data in the data block that corresponds to a specific plug. |
MFnAttribute | The base attribute function set. Function sets are available for specific types of attributes. These all inherit from MFnAttribute. If no class exists for the type of attribute you need, you can use the MFnTypedAttribute or MFnGenericAttribute. |
All nodes need to implement creator(), initialize(), initializePlugin(), and uninitializePlugin() . Nodes that process data need to implement the compute() method. These methods are all called by Maya at different times.
Function or method | Description |
---|---|
initializePlugin() | Called when a plug-in is loaded into Maya. Registers the plug-in. See Plug-in entry points for details. |
initialize() | Initializes node attributes. Called when the node is registered. |
creator() | Instantiates the node. Called each time a node is instantiated in the dependency graph. |
compute() | Computes the value of output attributes and sets them in the node's data block. Called the first time the dependency node graph is run, and then whenever an output plug on the node is dirty and needs to be recomputed. |
uninitializePlugin() | Called when a plug-in is unloaded from Maya. Deregisters the plug-in. See Plug-in entry points for details. |