Public Member Functions | Protected Member Functions

MFnTypedAttribute Class Reference

This reference page is linked to from the following overview topics: A more complex example, Generic Attributes, Appendix D: Frequently asked questions.


Search for all occurrences

Detailed Description

Typed attribute function set.

MFnTypedAttribute is the function set for typed dependency node attributes. A typed attribute accepts exactly one type of data. The type that it accepts is set when the attribute is created.

Once a typed attribute had been created, the data for it can be accessed using an MDataHandle while in your node's compute method.

Examples:

animCubeNode.cpp, apiMeshCreator.cpp, apiMeshShape.cpp, arcLenNode.cpp, blindComplexDataCmd.cpp, blindDataMesh.cpp, blindDoubleDataCmd.cpp, cgfxAttrDef.cpp, cgfxShaderNode.cpp, closestPointOnCurveNode.cpp, cvColorNode.cpp, fullLoftNode.cpp, geometrySurfaceConstraint.cpp, GLSLShaderNode.cpp, hlslShader.cpp, hwAnisotropicShader_NV20.cpp, hwColorPerVertexShader.cpp, hwDecalBumpShader_NV20.cpp, hwReflectBumpShader_NV20.cpp, hwRefractReflectShader_NV20.cpp, hwToonShader_NV20.cpp, hwUnlitShader.cpp, latticeNoiseNode.cpp, meshOpNode.cpp, multiCurveNode.cpp, particleAttrNode.cpp, pointOnMeshInfoNode.cpp, pointOnSubdNode.cpp, polyPrimitiveCmd.cpp, shellNode.cpp, simpleLoftNode.cpp, slopeShaderNode.cpp, splitUVNode.cpp, stringFormatNode.cpp, testNobjectNode.cpp, and testNucleusNode.cpp.

#include <MFnTypedAttribute.h>

Inheritance diagram for MFnTypedAttribute:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual MFn::Type type () const
 Function set type.
virtual ~MFnTypedAttribute ()
 Destructor.
 MFnTypedAttribute ()
 Default constructor.
 MFnTypedAttribute (MObject &object, MStatus *ReturnStatus=NULL)
 Constructor.
MObject create (const MString &fullName, const MString &briefName, const MTypeId &id, MObject defaultData=MObject::kNullObj, MStatus *ReturnStatus=NULL)
 Create a new typed attribute with the given type.
MObject create (const MString &fullName, const MString &briefName, MFnData::Type type, MObject defaultData=MObject::kNullObj, MStatus *ReturnStatus=NULL)
 Create a new typed attribute with the given type.
MFnData::Type attrType (MStatus *ReturnStatus=NULL) const
 Return the type of this attribute.
MStatus getDefault (MObject &defaultCustomData)
 Get the default data for this attribute.
MStatus setDefault (const MObject &defaultCustomData)
 Set the default data for this attribute.
MObject create (const MString &fullName, const MString &briefName, MFnData::Type type, MStatus *ReturnStatus)
 This method is obsolete. This method is not available in Python.
 MFnTypedAttribute (const MObject &object, MStatus *ReturnStatus=NULL)
 Constructor.

Protected Member Functions

virtual const char * className () const
 Class name.

Constructor & Destructor Documentation

MFnTypedAttribute ( 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:
MFnTypedAttribute ( const 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:

Member Function Documentation

MFn::Type type ( ) const [virtual]

Function set type.

Return the class type : MFn::kTypedAttribute.

Reimplemented from MFnAttribute.

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

Class name.

Return the class name : "MFnTypedAttribute".

Reimplemented from MFnAttribute.

MObject create ( const MString full,
const MString brief,
const MTypeId id,
MObject  defaultData = MObject::kNullObj,
MStatus ReturnStatus = NULL 
)

Create a new typed attribute with the given type.

Parameters:
[in]fullFull name for the new attribute.
[in]briefShort name for the attribute.
[in]idType id of the attribute's data.
[in]defaultDataDefault data for the attribute.
[out]ReturnStatusReturn status.
Returns:
Pointer to the new attribute object.
Status Codes:
Examples:
animCubeNode.cpp, apiMeshCreator.cpp, apiMeshShape.cpp, arcLenNode.cpp, blindComplexDataCmd.cpp, blindDataMesh.cpp, blindDoubleDataCmd.cpp, cgfxAttrDef.cpp, cgfxShaderNode.cpp, closestPointOnCurveNode.cpp, cvColorNode.cpp, fullLoftNode.cpp, geometrySurfaceConstraint.cpp, GLSLShaderNode.cpp, hlslShader.cpp, hwColorPerVertexShader.cpp, latticeNoiseNode.cpp, meshOpNode.cpp, multiCurveNode.cpp, particleAttrNode.cpp, pointOnMeshInfoNode.cpp, pointOnSubdNode.cpp, polyPrimitiveCmd.cpp, shellNode.cpp, simpleLoftNode.cpp, splitUVNode.cpp, stringFormatNode.cpp, testNobjectNode.cpp, and testNucleusNode.cpp.
MObject create ( const MString full,
const MString brief,
MFnData::Type  type,
MObject  defaultData = MObject::kNullObj,
MStatus ReturnStatus = NULL 
)

Create a new typed attribute with the given type.

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]fullFull name for the new attribute.
[in]briefShort name for the attribute.
[in]typeType of the attribute's data.
[in]defaultDataDefault data for the attribute.
[out]ReturnStatusReturn status.
Returns:
Pointer to the new attribute object.
Status Codes:
MFnData::Type attrType ( MStatus ReturnStatus = NULL) const

Return the type of this attribute.

Parameters:
[out]ReturnStatus
Returns:
An element of the MFnData::Type enum.
Status Codes:
  • MS::kSuccess The operation succeeded.
  • MS::kObjectDoesNotExist This instance is not bound to an MObject.
Examples:
cgfxAttrDef.cpp.
MStatus getDefault ( MObject defaultData)

Get the default data for this attribute.

The data can then be operated on using the appropriate MFn*Data functionset.

Parameters:
[out]defaultDatareceives a copy of the attribute's default data.
Returns:
Return status.
Status Codes:
  • MS::kSuccess Operation successful.
  • MS::kFailure Invalid type for default data, or function does not have a valid object.
MStatus setDefault ( const MObject defaultData)

Set the default data for this attribute.

The data can be created using the appropriate MFn*Data function set.

Parameters:
[in]defaultDatadefault data for the attribute
Returns:
Return status.
Status Codes:
  • MS::kSuccess Operation successful.
  • MS::kFailure Invalid type for default data, or function does not have a valid object.
Examples:
cvColorNode.cpp.
MObject create ( const MString full,
const MString brief,
MFnData::Type  type,
MStatus ReturnStatus 
)

This method is obsolete. This method is not available in Python.

Deprecated:
Use the other MFnTypedAttribute::create method instead.

Create a new typed attribute with the given type.

Parameters:
[in]fullFull name for the new attribute.
[in]briefShort name for the attribute.
[in]typeType of the attribute's data.
[out]ReturnStatusReturn status.
Returns:
Pointer to the new attribute object.
Status Codes:

MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute
MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute MFnTypedAttribute