C++ API Reference

A class for performing node class-level operations in the dependency graph. More...

#include <MNodeClass.h>

Public Member Functions

 MNodeClass (const MString &nodeClassName)
 Construct an MNodeClass object based on the given class name. More...
 
 MNodeClass (const MTypeId &nodeTypeId)
 Construct an MNodeClass object based on the given MTypeId. More...
 
MTypeId typeId () const
 Returns the type id of this node class. More...
 
MString typeName () const
 Returns the type name of this node class. More...
 
MString classification () const
 Retrieves the classification string for a node class. More...
 
MStatus addToClassification (const MString &str)
 Adds to the node class's classification string. More...
 
MStatus removeFromClassification (const MString &str)
 Removes an element from the node class's classification string. More...
 
MString pluginName (MStatus *ReturnStatus=NULL) const
 Returns the name of the plug-in this node class was defined in. More...
 
MStatus addExtensionAttribute (const MObject &attr) const
 Adds an extension attribute to the node class. More...
 
MStatus removeExtensionAttribute (const MObject &attr) const
 Removes an extension attribute from the node class. More...
 
MStatus removeExtensionAttributeIfUnset (const MObject &attr) const
 Removes an extension attribute from the given dependency node type but only if there are no nodes in the graph with non-default values for this attribute. More...
 
MStatus getAttributes (MObjectArray &attr) const
 Get the list of attributes for the node class. More...
 
unsigned int attributeCount (MStatus *ReturnStatus=NULL) const
 Get the number of attributes for the node class. More...
 
MObject attribute (unsigned int index, MStatus *ReturnStatus=NULL) const
 Finds the attribute of this node class at the given index. More...
 
MObject attribute (const MString &attrName, MStatus *ReturnStatus=NULL) const
 Finds the attribute of this node class that has the given name. More...
 
bool hasAttribute (const MString &attrName, MStatus *ReturnStatus=NULL) const
 Returns true if the node class already has an attribute with the given name. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Detailed Description

A class for performing node class-level operations in the dependency graph.

MNodeClass allows the manipulation of dependency graph node classes. Operations specific to a particular node should instead use MFnDependencyNode.

Constructor & Destructor Documentation

MNodeClass ( const MString nodeClassName)

Construct an MNodeClass object based on the given class name.

If the name cannot be resolved as a known class, the MNodeClass will refer to an MFn::kInvalid api type.

Parameters
[in]nodeClassNameclass name of the node type to wrap
OPENMAYA_MAJOR_NAMESPACE_OPEN MNodeClass ( const MTypeId nodeTypeId)

Construct an MNodeClass object based on the given MTypeId.

This can then be used to perform class-level operations.

Parameters
[in]nodeTypeIdid of the node type to wrap

Member Function Documentation

MTypeId typeId ( ) const

Returns the type id of this node class.

The type is is the 4 byte code that is used in the binary file format to identify the type of this node.

Returns
The type id of this node
MString typeName ( ) const

Returns the type name of this node class.

The string returned is the name of the node type as it is used in the ascii file format.

Returns
The type name of this node
MString classification ( ) const

Retrieves the classification string for a node class.

This is a string that is used in dependency nodes that are also shaders to provide more detailed type information to the rendering system. See the documentation for the MEL commands getClassification and listNodeTypes for information on the strings that can be provided.

User-defined nodes set this value through a parameter to MFnPlugin::registerNode.

Returns
The classification string. If the node class does not have an associated classification, an empty string will be returned.
MStatus addToClassification ( const MString str)

Adds to the node class's classification string.

See the classification() method, above.

Adding to the classification string is useful in conjunction with the MSwatchRenderRegister API, to override the swatch rendering of built-in Maya node types. Adding the classification 'swatch/File' causes nodes to use a simple default icon instead of their usual swatch rendering.

Parameters
[in]strThe string to add to the classification
Returns
Status of operation.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure new classification not added
  • MS::kInvalidParameter the string to add was invalid (e.g. contained the separator character (':'))
MStatus removeFromClassification ( const MString str)

Removes an element from the node class's classification string.

See the classification() method, above.

Parameters
[in]strThe string to remove from the classification
Returns
Status of operation.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure classification not removed
  • MS::kInvalidParameter the string to remove was invalid (e.g. contained the separator character (':'))
MString pluginName ( MStatus ReturnStatus = NULL) const

Returns the name of the plug-in this node class was defined in.

The name returned is the name of the plug-in on disk, and may contain pathname separators (such as `/') and drive letters (e.g. C:).

Parameters
[out]ReturnStatusreturn status
Returns
The name of the plug-in
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure node class was not found in plugin database
MStatus addExtensionAttribute ( const MObject attr) const

Adds an extension attribute to the node class.

An extension attribute is a class-level attribute which has been added dynamically to a node class. Because it is added at the class level, all nodes of that class will have the given attribute, and will only store the attribute's value if it differs from the default.

Parameters
[in]attrThe attribute to add
Returns
Status of operation.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure extension attribute was not added
  • MS::kInvalidParameter this node class was not a valid one for adding extensions
MStatus removeExtensionAttribute ( const MObject attr) const

Removes an extension attribute from the node class.

An extension attribute is a class-level attribute which has been added dynamically to a node class. Because it is added at the class level, all nodes of that class will have the given attribute, and will only store the attribute's value if it differs from the default.

Parameters
[in]attrThe attribute to remove
Returns
Status of operation.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure extension attribute was not removed
  • MS::kInvalidParameter attribute was not an extension on this class
MStatus removeExtensionAttributeIfUnset ( const MObject attr) const

Removes an extension attribute from the given dependency node type but only if there are no nodes in the graph with non-default values for this attribute.

An extension attribute is a class-level attribute which has been added dynamically to a node class. Because it is added at the class level, all nodes of that class will have the given attribute. This method will only remove the attribute if any of its node values differs from the default.

Parameters
[in]attrThe attribute to remove
Returns
Status of operation.
Status Codes:
  • MS::kSuccess extension attribute was removed
  • MS::kFailure extension attribute was not removed
  • MS::kInvalidParameter attribute was not an extension on this class
MStatus getAttributes ( MObjectArray attr) const

Get the list of attributes for the node class.

Parameters
[out]attrThe list of attributes
Returns
Status of operatation
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure unable to complete operation
unsigned int attributeCount ( MStatus ReturnStatus = NULL) const

Get the number of attributes for the node class.

Parameters
[out]ReturnStatusreturn status
Returns
The number of attributes.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure unable to count attributes
MObject attribute ( unsigned int  index,
MStatus ReturnStatus = NULL 
) const

Finds the attribute of this node class at the given index.

Index order is based on the order in which the attributes were added to the class.

Parameters
[in]indexthe index of the attribute
[out]ReturnStatusreturn status
Returns
The attribute, or kNullObj if no attribute existed at the given index
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure not a valid node class
  • MS::kInvalidParameter index is out of range
MObject attribute ( const MString attrName,
MStatus ReturnStatus = NULL 
) const

Finds the attribute of this node class that has the given name.

Parameters
[in]attrNamename of the attribute to find
[out]ReturnStatusreturn status
Returns
The attribute, or kNullObj if no attribute with the given name could be found
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the search could not be completed
bool hasAttribute ( const MString attrName,
MStatus ReturnStatus = NULL 
) const

Returns true if the node class already has an attribute with the given name.

Parameters
[in]attrNameName of attribute to be checked.
[out]ReturnStatusreturn status
Returns
true if the node class has attribute, false otherwise.
Status Codes:
  • MS::kSuccess operation is successful
  • MS::kFailure unable to complete operation
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.

The documentation for this class was generated from the following files: