C++ API Reference: MAttributePattern Class Reference
The pattern of an attribute tree that can be applied to nodes or node classes.
More...
#include <MAttributePattern.h>
The pattern of an attribute tree that can be applied to nodes or node classes.
Class that provides a pattern of attributes to be applied to nodes as dynamic attributes or to node classes as extension attributes.
An attribute pattern is a pattern describing an attribute tree. In the simplest implementation it can just store an internal copy of the tree to be applied. The code to apply the attribute patterns will use the rootAttr() and rootAttrCount() methods to iterate through the list of top level attributes to be applied. It presumes that if they are compounds then their children will already be parented properly.
for ( unsigned int i=0; i < tmpl.rootAttrCount(); ++i )
{
applyAttributesToNodes( tmpl.rootAttr(i), someNode );
}
When creating the pattern from inside MPxAttributePatternFactory you add only the root level attributes, i.e. the attributes without parents. As a simple example if your pattern factory has data that specifies creating a pattern with one integer attribute and one compound with three float children the code would like something like this.
MObject parentObj1 = parentAttr.
create (
"parent" ,
"par" , &status );
return ( (tmpl->
addRootAttr ( parentObj1 ) == MS::kSuccess)
&& (tmpl->
addRootAttr ( parentObj2 ) == MS::kSuccess) );
Construct an MAttributePattern object with the given name.
It can then be populated with the information required for it to be able to appy a set of attributes to a node or node class.
Parameters
[in] name Name of the pattern
Construct an MAttributePattern object from another pattern.
The internal Maya object is shared between the two MAttributePatterns.
Parameters
[in] rhs Pattern to be copied
Copy an MAttributePattern object from another pattern.
Parameters
[in] rhs Pattern to be copied
Determine equality between two attribute patterns.
Parameters
[in] rhs Pattern to be compared
Returns true if they both point to the same underlying Maya pattern
Look up an existing pattern by name.
Parameters
[in] name The name of the pattern to be found
Returns Pattern with the given name, NULL if not found
unsigned int attrPatternCount
(
)
static
Get the number of patterns currently known.
Returns Number of patterns that have been created.
Look up an existing pattern by index value.
Parameters
[in] n The index in the global list of the pattern to be found
Returns Pattern with the given index, NULL if out of range
Get the name of this pattern.
Parameters
[out] ReturnStatus Did the operation return valid data?
Returns Name of this pattern.
Status Codes:
MS::kSuccess The name was successfully returned.
MS::kFailure Object error.
unsigned int rootAttrCount
(
MStatus *
ReturnStatus = NULL
)
const
Get the number of top level attributes present in this pattern.
Parameters
[out] ReturnStatus Did the operation return valid data?
Returns Number of root attributes present in this pattern
Status Codes:
MS::kSuccess The count was successfully returned.
MS::kFailure Object error.
MObject rootAttr
(
unsigned int
idx ,
MStatus *
ReturnStatus = NULL
)
const
Get a single root-level attribute from this pattern.
Parameters
[in] idx Index of the root-level attribute in the pattern's list.
[out] ReturnStatus Did the operation return valid data?
Returns The idx'th root attribute present in the pattern.
Status Codes:
MS::kSuccess The attribute was successfully returned.
MS::kInvalidParameter There is no attribute at the given index.
MS::kFailure Object error.
MStatus removeRootAttr
(
unsigned int
idx )
Remove a single root attribute and its children from the pattern by index.
Parameters
[in] idx Index of the root attribute to be removed
Returns Status code of the operation's success
Status Codes:
MS::kSuccess The attribute was successfully removed from the pattern.
MS::kInvalidParameter There is no attribute at the given index.
MS::kFailure Object error.
Remove a single root attribute and its children from the pattern by attribute.
Parameters
[in] attr The attribute to be removed
Returns Status code of the operation's success
Status Codes:
MS::kSuccess The attribute was successfully removed from the pattern
MS::kFailure Removal was not possible.
MS::kInvalidParameter The given attribute is not in this pattern or is not a root
Add a new root attribute to the pattern.
Parameters
[in] attr Attribute to be added to this pattern.
Returns Status code of the operation's success
Status Codes:
MS::kSuccess The attribute was successfully added to the pattern
MS::kFailure Addition was not possible.
MS::kInvalidParameter The given attribute is already in this pattern or is not a root
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:
MAttributePattern.h
MAttributePattern.cpp