- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions

# MFnCompoundAttribute Class Reference

# OpenMaya - API module for common classes | FunctionSet classes

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:
[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] | object | The MObject to attach the function set to
  [out] | ReturnStatus | the return status

Status Codes:
  - MS::kSuccess if the function set is successfully attached
  - MS::kInvalidParameter if the MObject does not represent a valid Maya object or if the function set is not allowed to attach to this MObject

MFnCompoundAttribute | ( | const MObject & | object,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

NO SCRIPT SUPPORT.

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

Constructor

Parameters:

  [in] | object | The MObject to attach the function set to
  [out] | ReturnStatus | the return status

Status Codes:
  - MS::kSuccess if the function set is successfully attached
  - MS::kInvalidParameter if the MObject does not represent a valid Maya object or if the function set is not allowed to attach to this MObject

## Member Function Documentation

MFn::Type type | ( |  | ) | const `[virtual]`

Search for all occurrences

Function set type.

Return the class type : MFn::kCompoundAttribute.

Reimplemented from MFnAttribute.

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

Search for all occurrences

Class name.

Return the class name : "MFnCompoundAttribute".

Reimplemented from MFnAttribute.

MObject create | ( | const MString & | full,
|  | const MString & | brief,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Search for all occurrences

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] | full | Long name of the attribute.
  [in] | brief | Short name of the attribute.
  [out] | ReturnStatus | Status code.

Returns:
  Return status

Status Codes:
  - MS::kSuccess operation successful
  - MS::kInsufficientMemory out of memory

Examples:
  geometrySurfaceConstraint.cpp, and weightListNode.cpp.

MStatus addChild | ( | const MObject & | child | ) |

Search for all occurrences

Add a child attribute under this compound attribute.

Parameters:

  [in] | child | new child attribute

Returns:
  Return status

Status Codes:
  - MS::kSuccess operation successful
  - MS::kInvalidParameter argument is not a valid attribute, or has a larger alignment requirement than the first child in this compound attribute.
  - MS::kFailure adding child failed

Examples:
  geometrySurfaceConstraint.cpp, and weightListNode.cpp.

MStatus removeChild | ( | const MObject & | child | ) |

Search for all occurrences

Remove a child attribute from this compound attribute.

Parameters:

  [in] | child | child attribute to remove

Returns:
  Return status

Status Codes:
  - MS::kSuccess operation successful
  - MS::kInvalidParameter argument is not a valid attribute
  - MS::kFailure removing child failed

unsigned int numChildren | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

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

Parameters:

  [out] | ReturnStatus | return status

Returns:
  The number of children

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure function set does not have a valid object

Examples:
  cgfxAttrDef.cpp.

MObject child | ( | unsigned int | index,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | const

Search for all occurrences

Get a child of this compound attribute.

Parameters:

  [in] | index | index of child
  [out] | ReturnStatus | return status

Returns:
  The child attribute

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure function set does not have a valid object

Examples:
  cgfxAttrDef.cpp.

MStatus getAddAttrCmds | ( | MStringArray & | cmds,
|  | bool | useLongNames = `false`
| ) |  | const

Search for all occurrences

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] | cmds | string array to receive the adAttr commands
  [in] | useLongNames | if true, long attribute names are used rather than short

Returns:
  Return status

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed
  - MS::kInvalidParameter function set is not bound to an attribute

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