Public Member Functions | Protected Member Functions

MFnCompoundAttribute Class Reference

This reference page is linked to from the following overview topics: Complex Attributes.


Search for all occurrences

Detailed Description

Compound attribute function set.

MFnCompoundAttribute is the function set for compound dependency node attributes.

Compound attributes allow the grouping of related attributes into a larger unit. It is possible to connect to a compound attribute as a whole, or to any of the individual children.

For example, the three attributes RED, GREEN, and BLUE could be grouped into a compound attribute of type COLOR. It is then possible to connect two COLOR attributes together. This removes the need to connect each child explicitly.

A second use for compound attributes is when there are multi attributes that relate to each other on an element-by-element basis. An example of this is the weighted matrix node that has a multi attribute with matrices that must be matched with the multi attribute that provides the weights for each matrix.

Examples:

cgfxAttrDef.cpp, clearcoat.cpp, geometrySurfaceConstraint.cpp, maTranslator.cpp, and weightListNode.cpp.

#include <MFnCompoundAttribute.h>

Inheritance diagram for MFnCompoundAttribute:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual MFn::Type type () const
 Function set type.
virtual ~MFnCompoundAttribute ()
 Destructor.
 MFnCompoundAttribute ()
 Default constructor.
 MFnCompoundAttribute (MObject &object, MStatus *ReturnStatus=NULL)
 Constructor.
MObject create (const MString &full, const MString &brief, MStatus *ReturnStatus=NULL)
 Creates a new compound attribute.
MStatus addChild (const MObject &child)
 Add a child attribute under this compound attribute.
MStatus removeChild (const MObject &child)
 Remove a child attribute from this compound attribute.
unsigned int numChildren (MStatus *ReturnStatus=NULL) const
 Returns the number of child attributes that this compound attribute has.
MObject child (unsigned int index, MStatus *ReturnStatus=NULL) const
 Get a child of this compound attribute.
MStatus getAddAttrCmds (MStringArray &cmds, bool useLongNames=false) const
 Returns a string array containing the addAttr commands which would be required to recreate the attribute and all of its descendents on a node.
 MFnCompoundAttribute (const MObject &object, MStatus *ReturnStatus=NULL)
 NO SCRIPT SUPPORT.

Protected Member Functions

virtual const char * className () const
 Class name.

Constructor & Destructor Documentation

MFnCompoundAttribute ( MObject object,
MStatus ReturnStatus = NULL 
)

Constructor.

Class constructor that initializes the function set to the given MObject.

Parameters:
[in]objectThe MObject to attach the function set to
[out]ReturnStatusthe return status
Status Codes:
MFnCompoundAttribute ( const MObject object,
MStatus ReturnStatus = NULL 
)

NO SCRIPT SUPPORT.

Class constructor that initializes the function set to the given MObject.

Constructor

Parameters:
[in]objectThe MObject to attach the function set to
[out]ReturnStatusthe return status
Status Codes:

Member Function Documentation

MFn::Type type ( ) const [virtual]

Function set type.

Return the class type : MFn::kCompoundAttribute.

Reimplemented from MFnAttribute.

const char * className ( ) const [protected, virtual]

Class name.

Return the class name : "MFnCompoundAttribute".

Reimplemented from MFnAttribute.

MObject create ( const MString full,
const MString brief,
MStatus ReturnStatus = NULL 
)

Creates a new compound attribute.

The create method needs to be called on a per node basis. That means if you want to create and add the same attribute to multiple nodes, you need to call the create method for each node to get a unique MObject back. If you call create just once and add the attribute to multiple nodes, Maya will encounter a fatal error.

Parameters:
[in]fullLong name of the attribute.
[in]briefShort name of the attribute.
[out]ReturnStatusStatus code.
Returns:
Return status
Status Codes:
Examples:
geometrySurfaceConstraint.cpp, and weightListNode.cpp.
MStatus addChild ( const MObject child)

Add a child attribute under this compound attribute.

Parameters:
[in]childnew child attribute
Returns:
Return status
Status Codes:
Examples:
geometrySurfaceConstraint.cpp, and weightListNode.cpp.
MStatus removeChild ( const MObject child)

Remove a child attribute from this compound attribute.

Parameters:
[in]childchild attribute to remove
Returns:
Return status
Status Codes:
unsigned int numChildren ( MStatus ReturnStatus = NULL) const

Returns the number of child attributes that this compound attribute has.

Parameters:
[out]ReturnStatusreturn status
Returns:
The number of children
Status Codes:
Examples:
cgfxAttrDef.cpp.
MObject child ( unsigned int  index,
MStatus ReturnStatus = NULL 
) const

Get a child of this compound attribute.

Parameters:
[in]indexindex of child
[out]ReturnStatusreturn status
Returns:
The child attribute
Status Codes:
Examples:
cgfxAttrDef.cpp.
MStatus getAddAttrCmds ( MStringArray cmds,
bool  useLongNames = false 
) const

Returns a string array containing the addAttr commands which would be required to recreate the attribute and all of its descendents on a node.

The attributes are returned in depth-first order, meaning that element 0 of the array will contain this attribute's addAttr command, element 1 will contain the command for its first child, element 2 will contain the command for its first child's child, if one exists, and so on.

Each command is returned with the terminating semicolon and is formatted as if for use with a selected node, meaning that no node name is supplied.

Parameters:
[out]cmdsstring array to receive the adAttr commands
[in]useLongNamesif true, long attribute names are used rather than short
Returns:
Return status
Status Codes:

MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute
MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute MFnCompoundAttribute