C++ API Reference

Dependency node attribute function set. More...

#include <MFnAttribute.h>

+ Inheritance diagram for MFnAttribute:

Public Types

enum  DisconnectBehavior { kDelete, kReset, kNothing }
 Attribute behaviour on disconnect. More...
 

Public Member Functions

virtual MFn::Type type () const
 Function set type. More...
 
virtual ~MFnAttribute ()
 Destructor.
 
 MFnAttribute ()
 Default constructor.
 
 MFnAttribute (MObject &object, MStatus *ReturnStatus=NULL)
 Constructor. More...
 
bool isReadable (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is readable. More...
 
bool isWritable (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is writable. More...
 
bool isConnectable (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute accepts dependency graph connections. More...
 
bool isStorable (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is to be stored when the node is saved to a file. More...
 
bool isCached (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is cached locally in the node's data block. More...
 
bool isArray (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute supports an array of data. More...
 
bool indexMatters (MStatus *ReturnStatus=NULL) const
 Determines whether the user must specify an index when connecting to this attribute, or whether the next available index can be used. More...
 
bool isKeyable (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is keyable. More...
 
bool isChannelBoxFlagSet (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute has its channel box flag set. More...
 
bool isHidden (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is to hidden from the UI. More...
 
bool isUsedAsColor (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is to be presented as a color in the UI. More...
 
bool isIndeterminant (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is indeterminant. More...
 
bool isRenderSource (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is a render source. More...
 
bool isDynamic (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is a dynamic attribute. More...
 
bool isExtension (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is an extension attribute. More...
 
bool isWorldSpace (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is worldspace. More...
 
bool isAffectsWorldSpace (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute affects worldspace. More...
 
bool isUsedAsFilename (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is to be used as a filename. More...
 
bool affectsAppearance (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute affects the appearance of the object when rendering in the viewport. More...
 
bool isProxyAttribute (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute is a proxy attribute. More...
 
DisconnectBehavior disconnectBehavior (MStatus *ReturnStatus=NULL) const
 Returns the behavior of this attribute when it is disconnected. More...
 
bool usesArrayDataBuilder (MStatus *ReturnStatus=NULL) const
 Returns true if this attribute uses an array data builder. More...
 
bool internal (MStatus *ReturnStatus=NULL) const
 Returns true if a node has internal member data representing this attribute. More...
 
MStatus setReadable (bool state)
 Sets whether this attribute should be readable. More...
 
MStatus setWritable (bool state)
 Sets whether this attribute should be writable. More...
 
MStatus setConnectable (bool state)
 Sets whether this attribute should allow dependency graph connections. More...
 
MStatus setStorable (bool state)
 Sets whether this attribute should be storable. More...
 
MStatus setCached (bool state)
 Sets whether the data for this attribute is cached locally in the node's data block. More...
 
MStatus setArray (bool state)
 Sets whether this attribute should have an array of data. More...
 
MStatus setIndexMatters (bool state)
 If the attribute is an array, then this method specifies whether to force the user to specify an index when connecting to this attribute, or to use the next available index. More...
 
MStatus setKeyable (bool state)
 Sets whether this attribute should accept keyframe data. More...
 
MStatus setChannelBox (bool state)
 Sets whether this attribute should appear in the channel box when the node is selected. More...
 
MStatus setHidden (bool state)
 Sets whether this attribute should be hidden from the UI. More...
 
MStatus setUsedAsColor (bool state)
 Sets whether this attribute should be presented as a color in the UI. More...
 
MStatus setIndeterminant (bool state)
 Sets whether this attribute is indeterminant. More...
 
MStatus setRenderSource (bool state)
 Sets whether this attribute should be used as a render source attribute. More...
 
MStatus setWorldSpace (bool state)
 Sets whether this attribute should be treated as worldspace. More...
 
MStatus setAffectsWorldSpace (bool state)
 Sets whether this attribute should affect worldspace. More...
 
MStatus setUsedAsFilename (bool state)
 Sets whether this attribute should be presented as a filename in the UI. More...
 
MStatus setAffectsAppearance (bool state)
 Sets whether this attribute affects the appearance of the object when rendering in the viewport. More...
 
MStatus setProxyAttribute (bool state)
 Sets whether this attribute is a proxy attribute. More...
 
MStatus setDisconnectBehavior (DisconnectBehavior behavior)
 Sets the disconnection behavior for this attribute. More...
 
MStatus setUsesArrayDataBuilder (bool state)
 Sets whether this attribute uses an array data builder. More...
 
MStatus setInternal (bool state)
 The function controls an attribute's data storage. More...
 
MStatus setNiceNameOverride (const MString &localizedName)
 Sets the localized string which should be used for this attribute in the UI. More...
 
bool acceptsAttribute (const MFnAttribute &attr, MStatus *ReturnStatus=NULL) const
 Returns true if this attribute can accept a connection with the given attribute. More...
 
bool accepts (MFnData::Type type, MStatus *ReturnStatus=NULL) const
 Returns true if this attribute can accept a connection of the given type. More...
 
bool accepts (const MTypeId &id, MStatus *ReturnStatus=NULL) const
 Returns true if this attribute can accept a connection of the given type. More...
 
MObject parent (MStatus *ReturnStatus=NULL) const
 Get the parent of this attribute, if it has one. More...
 
MString name (MStatus *ReturnStatus=NULL) const
 Returns the long name of the attribute. More...
 
MString shortName (MStatus *ReturnStatus=NULL) const
 Returns the short name of the attribute. More...
 
MString getAddAttrCmd (bool useLongName=false, MStatus *status=NULL) const
 Returns a string containing the addAttr command which would be required to recreate the attribute on a node. More...
 
MStatus addToCategory (const MString &category)
 Add the attribute to the named category. More...
 
MStatus removeFromCategory (const MString &category)
 Remove the attribute from the named category. More...
 
bool hasCategory (const MString &category) const
 Check to see if the attribute belongs to the named category. More...
 
MStatus getCategories (MStringArray &ReturnStatus) const
 Get all of the categories to which this attribute belongs. More...
 
 MFnAttribute (const MObject &object, MStatus *ReturnStatus=NULL)
 NO SCRIPT SUPPORT. More...
 
- Public Member Functions inherited from MFnBase
virtual ~MFnBase ()
 Class Destructor. More...
 
bool hasObj (MFn::Type) const
 Determines whether or not the Function Set is compatible with the specified Maya Object within the API RTTI system. More...
 
bool hasObj (const MObject &) const
 Determines whether or not the Function Set is compatible with the specified Maya Object within the API RTTI system. More...
 
MObject object (MStatus *ReturnStatus=nullptr) const
 Returns the MObject that is attached to the Function Set. More...
 
virtual MStatus setObject (MObject &object)
 Attaches the Function Set to the specified Maya Object. More...
 
virtual MStatus setObject (const MObject &object)
 NO SCRIPT SUPPORT. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 
- Static Public Member Functions inherited from MFnBase
static const char * className ()
 Returns the name of this class. More...
 
static const char * typeString (MFn::Type)
 Returns the type string for a given type. More...
 
static bool isValid (MFn::Type)
 Returns true if type is in the range of valid types. More...
 

Detailed Description

Dependency node attribute function set.

MFnAttribute is the function set for dependency node attributes.

An attribute of a dependency node describes a piece of data that belongs to nodes of that type. For example, a node that makes a sphere might have a radius attribute. A node's attributes describe connections sites on the node that can be used in the dependency graph.

Attributes typically belong to a class of nodes, rather than to an individual node. For example, all sphere nodes have a radius. Even though a single attribute may be shared by all nodes of a given type, each node will have its own value for the attribute.

Attributes are hierarchical. For example, the translate scale attribute of a transform has x, y, and z child attributes.

By default, attributes are:

  • Readable.
  • Writable.
  • Connectable.
  • Storable.
  • Cached.
  • Not arrays.
  • Have indices that matter.
  • Do not use an array builder.
  • Not keyable.
  • Not hidden.
  • Not used as colors.
  • Not indeterminant.
  • Set to disconnect behavior kNothing.
Examples:
AbcBullet/AttributesWriter.cpp, AbcExport/AttributesWriter.cpp, AbcExport/MayaUtility.cpp, animExportUtil/animExportUtil.cpp, apiMeshShape/apiMeshShape.cpp, atomImportExport/atomAnimLayers.cpp, atomImportExport/atomCachedPlugs.cpp, atomImportExport/atomFileUtils.cpp, cgFx/cgfxAttrDef.cpp, cgFx/cgfxShaderNode.cpp, dagPoseInfoCmd/dagPoseInfoCmd.cpp, dx11Shader/dx11Shader.cpp, fileTexture/fileTexture.cpp, getAttrAffectsCmd/getAttrAffectsCmd.cpp, glslShader/GLSLShader.cpp, gpuCache/gpuCacheSubSceneOverride.cpp, and maTranslator/maTranslator.cpp.

Member Enumeration Documentation

Attribute behaviour on disconnect.

Enumerator
kDelete 

Delete array element (array attributes only).

kReset 

Reset the attribute to its default.

kNothing 

Do nothing to the attribute's value.

Constructor & Destructor Documentation

MFnAttribute ( 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:
  • 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
MFnAttribute ( 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:
  • 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

Function set type.

Return the class type : MFn::kAttribute.

Returns
the class type.

Reimplemented from MFnBase.

Reimplemented in MFnCompoundAttribute, MFnNumericAttribute, MFnUnitAttribute, MFnGenericAttribute, MFnTypedAttribute, MFnMessageAttribute, MFnLightDataAttribute, MFnEnumAttribute, and MFnMatrixAttribute.

OPENMAYA_MAJOR_NAMESPACE_OPEN const char * className ( )
static

Returns the name of this class.

Return the class name : "MFnAttribute".

Returns
Name of this class.
bool isReadable ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is readable.

If an attribute is readable, then it can be used as the source in a dependency graph connection.

Attributes are readable by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is readable
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isWritable ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is writable.

If an attribute is writable, then it can be used as the destination in a dependency graph connection.

Attributes are writable by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is writable
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isConnectable ( MStatus ReturnStatus = NULL) const

Returns true if this attribute accepts dependency graph connections.

If it does, then the readable and writable methods will indicate what types of connections are accepted.

Attributes are connectable by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is connectable
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isStorable ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is to be stored when the node is saved to a file.

Attributes are storable by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is storable
Status Codes:
  • kSuccess operation successful
  • kFailure this function set does not have a valid attribute object
bool isCached ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is cached locally in the node's data block.

The default for this is true. Caching a node locally causes a copy of the attribute value for the node to be cached with the node. This removes the need to traverse through the graph to get the value each time it is requested.

Caching the value locally gives a speed increase at the cost of more memory.

Attributes are cached by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is cached locally
Status Codes:
  • kSuccess operation successful
  • kFailure this function set does not have a valid attribute object
bool isArray ( MStatus ReturnStatus = NULL) const

Returns true if this attribute supports an array of data.

Attributes are single elements by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute stores an array of data
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool indexMatters ( MStatus ReturnStatus = NULL) const

Determines whether the user must specify an index when connecting to this attribute, or whether the next available index can be used.

This method only applies to array attributes which are non readable, i.e. destination attributes.

This corresponds with the connectAttr command's -na/nextAvailable flag. If the destination attribute has set the indexMatters to be false with this flag specified, a connection is made to the next available index. No index need be specified

The index matters to attributes by default.

Parameters
[out]ReturnStatusreturn status
Returns
  • true The user must specify the index when connecting to this attribute using connectAttr
  • false The next available index can be used when connecting to this attribute using connectAttr -na
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isKeyable ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is keyable.

Keyable attributes will be keyed by AutoKey and the Set Keyframe UI. Non-keyable attributes prevent the user from setting keys via the obvious UI provided for keying. Being non-keyable is not a hard block against adding keys to an attribute.

This method determines the default keyability of a plug. The keyability can be changed after it is created. Use the MPlug::isKeyable method to determine whether or not a specific plug is keyable.

Attributes are not keyable by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is keyable
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isChannelBoxFlagSet ( MStatus ReturnStatus = NULL) const

Returns true if this attribute has its channel box flag set.

Attributes will appear in the channel box if their channel box flag is set or if they are keyable.

This method returns the default channel box display state of a plug. The display can be changed after it is created. Use the MPlug::isChannelBox method to determine whether or not a specific plug is displayed in the channel box.

Attributes are not in the channel box by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating the status of the channel box flag on this attribute
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isHidden ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is to hidden from the UI.

The attribute will not show up in attribute editors.

Attributes are not hidden by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is hidden
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isUsedAsColor ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is to be presented as a color in the UI.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is used as a color
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcBullet/AttributesWriter.cpp, and AbcExport/AttributesWriter.cpp.
bool isIndeterminant ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is indeterminant.

If an attribute may or may not be used during an evaluation then it is indeterminant. This attribute classification is mainly used on rendering nodes to indicate that some attributes are not always used.

Attributes are not indeterminant by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is indeterminant
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isRenderSource ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is a render source.

This attribute is used on rendering nodes to override the rendering sampler info.

Attributes are not render source by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is render source
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isDynamic ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is a dynamic attribute.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is dynamic
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isExtension ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is an extension 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, and will only store the attribute's value if it differs from the default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is an extension attribute
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isWorldSpace ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is worldspace.

Attributes are not worldspace by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is worldspace
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isAffectsWorldSpace ( MStatus ReturnStatus = NULL) const

Returns true if this attribute affects worldspace.

Attributes do not affect worldspace by default.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute affects worldspace
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isUsedAsFilename ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is to be used as a filename.

In the UI this attr will be presented as a file name.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is used as a filename
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool affectsAppearance ( MStatus ReturnStatus = NULL) const

Returns true if this attribute affects the appearance of the object when rendering in the viewport.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute affects the appearance of the object when rendering in the viewport.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool isProxyAttribute ( MStatus ReturnStatus = NULL) const

Returns true if this attribute is a proxy attribute.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute is a proxy attribute
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
MFnAttribute::DisconnectBehavior disconnectBehavior ( MStatus ReturnStatus = NULL) const

Returns the behavior of this attribute when it is disconnected.

The possible settings are as follows:

  • kDelete delete the element of the array that was connected. This is only used for array attributes
  • kReset reset the attribute to its default value
  • kNothing leave the attribute set to its last known value

Attributes have a default disconnect behavior of kNothing.

Parameters
[out]ReturnStatusreturn status
Returns
The disconnect behavior
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool usesArrayDataBuilder ( MStatus ReturnStatus = NULL) const

Returns true if this attribute uses an array data builder.

If so, then the MArrayDataBuilder class may be used with this attribute.

By default array attributes do not use an array data builder.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute uses an array data builder.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool internal ( MStatus ReturnStatus = NULL) const

Returns true if a node has internal member data representing this attribute.

Parameters
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether this attribute uses internal data
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
MStatus setReadable ( bool  state)

Sets whether this attribute should be readable.

If an attribute is readable, then it can be used as the source in a dependency graph connection.

Attributes are readable by default.

Parameters
[in]statewhether the attribute is to be readable
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
anisotropicShader/anisotropicShader.cpp, backfillShader/backfillShader.cpp, clearcoat.cpp, closestPointOnCurve/closestPointOnCurveNode.cpp, customComponentTagNode/customComponentTagNode.cpp, displacementShader/displacementShader.cpp, dynExprField/dynExprField.cpp, footPrintNode_AnimatedMaterial/footPrintNode_GeometryOverride_AnimatedMaterial.cpp, geometrySurfaceConstraint/geometrySurfaceConstraint.cpp, geometrytools.cpp, interpShader/interpShader.cpp, lambertShader/lambertShader.cpp, lightShader/lightShader.cpp, multiCurveNode/multiCurveNode.cpp, onbShader/onbShader.cpp, phongShader/phongShader.cpp, pointOnMeshInfo/pointOnMeshInfoNode.cpp, pointOnSubdNode/pointOnSubdNode.cpp, shadowMatteShader/shadowMatteShader.cpp, shiftNode/shiftNode.cpp, simpleEvaluationDraw/simpleEvaluationDraw.cpp, simpleEvaluationNode/simpleEvaluationNode.cpp, simplePhysicsEngine/simplePhysicsEngine.cpp, simpleSimulationNode/simpleSimulationNode.cpp, slopeShader/slopeShaderNode.cpp, stringFormatNode/stringFormatNode.cpp, testMTopologyEvaluator/testMTopologyEvaluator.cpp, volumeShader/volumeShader.cpp, and weightListNode/weightListNode.cpp.
MStatus setWritable ( bool  state)

Sets whether this attribute should be writable.

If an attribute is writable, then it can be used as the destination in a dependency graph connection.

If both keyable and writable for an attribute are set to true it will be displayed in the channel box when the node is selected.

Attributes are writable by default.

Parameters
[in]statewhether the attribute is to be writable
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcImport/AlembicNode.cpp, anisotropicShader/anisotropicShader.cpp, arcLenNode/arcLenNode.cpp, backfillShader/backfillShader.cpp, cgFx/cgfxVector.cpp, circleNode/circleNode.cpp, clearcoat.cpp, closestPointOnCurve/closestPointOnCurveNode.cpp, customComponentTagNode/customComponentTagNode.cpp, displacementShader/displacementShader.cpp, dx11Shader/dx11Shader.cpp, dynExprField/dynExprField.cpp, exampleFalloff/smoothFalloffNode.cpp, footPrintManip/footPrintManip.cpp, footPrintNode/footPrintNode.cpp, footPrintNode_AnimatedMaterial/footPrintNode_GeometryOverride_AnimatedMaterial.cpp, footPrintNode_GeometryOverride/footPrintNode_GeometryOverride.cpp, genericAttributeNode/genericAttributeNode.cpp, geometrySurfaceConstraint/geometrySurfaceConstraint.cpp, geometrytools.cpp, glslShader/GLSLShader.cpp, hlslShader/hlslShader.cpp, interpShader/interpShader.cpp, jitterNode/jitterNode.cpp, lambertShader/lambertShader.cpp, latticeNoise/latticeNoiseNode.cpp, lightShader/lightShader.cpp, meshOpCmd/meshOpNode.cpp, MetadataSample/tweakMetadataNode.cpp, multiCurveNode/multiCurveNode.cpp, onbShader/onbShader.cpp, particleAttrNode/particleAttrNode.cpp, phongShader/phongShader.cpp, pointOnMeshInfo/pointOnMeshInfoNode.cpp, pointOnSubdNode/pointOnSubdNode.cpp, renderAccessNode/renderAccessNode.cpp, shadowMatteShader/shadowMatteShader.cpp, shellNode/shellNode.cpp, shiftNode/shiftNode.cpp, simpleEvaluationDraw/simpleEvaluationDraw.cpp, simpleEvaluationNode/simpleEvaluationNode.cpp, simplePhysicsEngine/simplePhysicsEngine.cpp, simpleSimulationNode/simpleSimulationNode.cpp, simpleSkipNode/simpleSkipNode.cpp, sineNode/sineNode.cpp, slopeShader/slopeShaderNode.cpp, splitUVCmd/splitUVNode.cpp, stringFormatNode/stringFormatNode.cpp, swissArmyManip/swissArmyManip.cpp, testMTopologyEvaluator/testMTopologyEvaluator.cpp, testNobjectNode/testNobjectNode.cpp, testNpassiveNode/testNpassiveNode.cpp, testNsolverNode/testNsolverNode.cpp, testNucleusNode/testNucleusNode.cpp, transCircleNode/transCircleNode.cpp, and volumeShader/volumeShader.cpp.
MStatus setConnectable ( bool  state)

Sets whether this attribute should allow dependency graph connections.

This should only get called in the initialize call of your node creator.

Attributes are connectable by default.

Parameters
[in]statewhether the attribute is to be connectable
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
basicMorphNode/basicMorphNode.cpp, buildRotationNode/buildRotationNode.cpp, cgFx/cgfxShaderNode.cpp, dx11Shader/dx11ConeAngleToHotspotConverter.cpp, footPrintNode_AnimatedMaterial/footPrintNode_GeometryOverride_AnimatedMaterial.cpp, footPrintNode_GeometryOverride/footPrintNode_GeometryOverride.cpp, MayaPluginForSpreticle/spReticleLoc.cpp, offsetNode/offsetNode.cpp, simplePhysicsEngine/simplePhysicsEngine.cpp, and testMTopologyEvaluator/testMTopologyEvaluator.cpp.
MStatus setStorable ( bool  state)

Sets whether this attribute should be storable.

If an attribute is storable, then it will be writen out when the node is stored to a file. This should only get called in the initialize call of your node creator.

Attributes are storable by default.

NOTE: Typed attributes of setting MFnData::kDynArrayAttrs are not storable. Message attribute are also not storable.

Parameters
[in]statewhether the attribute is to be storable
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcImport/AlembicNode.cpp, animCubeNode/animCubeNode.cpp, anisotropicShader/anisotropicShader.cpp, backfillShader/backfillShader.cpp, basicMorphNode/basicMorphNode.cpp, blindDataShader/blindDataMesh.cpp, buildRotationNode/buildRotationNode.cpp, cgFx/cgfxVector.cpp, circleNode/circleNode.cpp, clearcoat.cpp, closestPointOnCurve/closestPointOnCurveNode.cpp, customComponentTagNode/customComponentTagNode.cpp, customImagePlane/customImagePlane.cpp, displacementShader/displacementShader.cpp, dx11Shader/dx11ConeAngleToHotspotConverter.cpp, dx11Shader/dx11Shader.cpp, dynExprField/dynExprField.cpp, exampleFalloff/smoothFalloffNode.cpp, footPrintManip/footPrintManip.cpp, footPrintNode_AnimatedMaterial/footPrintNode_GeometryOverride_AnimatedMaterial.cpp, footPrintNode_GeometryOverride/footPrintNode_GeometryOverride.cpp, fullLoftNode/fullLoftNode.cpp, gameInputDevice/gameInputDevice.cpp, genericAttributeNode/genericAttributeNode.cpp, geomShader/geomShader.cpp, glslShader/GLSLShader.cpp, hlslShader/hlslShader.cpp, hwPhongShader/hwPhongShader.cpp, interpShader/interpShader.cpp, jitterNode/jitterNode.cpp, lambertShader/lambertShader.cpp, lightShader/lightShader.cpp, meshOpCmd/meshOpNode.cpp, MetadataSample/tweakMetadataNode.cpp, offsetNode/offsetNode.cpp, onbShader/onbShader.cpp, particleAttrNode/particleAttrNode.cpp, phongShader/phongShader.cpp, pointOnMeshInfo/pointOnMeshInfoNode.cpp, pointOnSubdNode/pointOnSubdNode.cpp, renderAccessNode/renderAccessNode.cpp, sceneAssembly/assemblyDefinition.cpp, shadowMatteShader/shadowMatteShader.cpp, shellNode/shellNode.cpp, shiftNode/shiftNode.cpp, simpleEvaluationDraw/simpleEvaluationDraw.cpp, simpleEvaluationNode/simpleEvaluationNode.cpp, simpleLoftNode/simpleLoftNode.cpp, simplePhysicsEngine/simplePhysicsEngine.cpp, simpleSimulationNode/simpleSimulationNode.cpp, simpleSkipNode/simpleSkipNode.cpp, sineNode/sineNode.cpp, slopeShader/slopeShaderNode.cpp, splatDeformer/splatDeformer.cpp, splitUVCmd/splitUVNode.cpp, sseDeformer/sseDeformer.cpp, stringFormatNode/stringFormatNode.cpp, swissArmyManip/swissArmyManip.cpp, testMTopologyEvaluator/testMTopologyEvaluator.cpp, testNobjectNode/testNobjectNode.cpp, testNpassiveNode/testNpassiveNode.cpp, testNsolverNode/testNsolverNode.cpp, testNucleusNode/testNucleusNode.cpp, transCircleNode/transCircleNode.cpp, volumeShader/volumeShader.cpp, and vp2BlinnShader/vp2BlinnShader.cpp.
MStatus setCached ( bool  state)

Sets whether the data for this attribute is cached locally in the node's data block.

The default for this is true. Caching a node locally causes a copy of the attribute value for the node to be cached with the node. This removes the need to traverse through the graph to get the value each time it is requested. This should only get called in the initialize call of your node creator.

Caching the value locally gives a speed increase at the cost of more memory.

Attributes are cached by default.

Parameters
[in]statewhether the attribute is to be cached locally
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
closestPointOnCurve/closestPointOnCurveNode.cpp, customComponentTagNode/customComponentTagNode.cpp, footPrintNode/footPrintNode.cpp, hwPhongShader/hwPhongShader.cpp, pointOnMeshInfo/pointOnMeshInfoNode.cpp, pointOnSubdNode/pointOnSubdNode.cpp, and shellNode/shellNode.cpp.
MStatus setArray ( bool  state)

Sets whether this attribute should have an array of data.

This should be set to true if the attribute needs to accept multiple incoming connections.

Attributes are single elements by default.

Parameters
[in]statewhether the attribute is to have an array of data
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcImport/AlembicNode.cpp, anisotropicShader/anisotropicShader.cpp, backfillShader/backfillShader.cpp, cameraSetSubclass/exCameraSet.cpp, cgFx/cgfxShaderNode.cpp, footPrintNode/footPrintNode.cpp, fullLoftNode/fullLoftNode.cpp, geometrySurfaceConstraint/geometrySurfaceConstraint.cpp, lambertShader/lambertShader.cpp, MayaPluginForSpreticle/spReticleLoc.cpp, multiCurveNode/multiCurveNode.cpp, onbShader/onbShader.cpp, phongShader/phongShader.cpp, sceneAssembly/assemblyDefinition.cpp, shadowMatteShader/shadowMatteShader.cpp, slopeShader/slopeShaderNode.cpp, stringFormatNode/stringFormatNode.cpp, testNsolverNode/testNsolverNode.cpp, testNucleusNode/testNucleusNode.cpp, and weightListNode/weightListNode.cpp.
MStatus setIndexMatters ( bool  state)

If the attribute is an array, then this method specifies whether to force the user to specify an index when connecting to this attribute, or to use the next available index.

This corresponds with the connectAttr command's -na/nextAvailable flag. If the destination attribute has set the indexMatters to be false with this flag specified, a connection is made to the next available index. No index need be specified

This method will only affect array attributes with setReadable set to false, i.e. destination attributes.

The index matters to attributes by default.

Parameters
[in]statewhether the attribute's index must be specified when connecting to this attribute using the connectAttr command
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kInvalidParameter attribute is readable
  • MS::kFailure this function set does not have a valid attribute object
Examples:
MayaPluginForSpreticle/spReticleLoc.cpp, slopeShader/slopeShaderNode.cpp, and stringFormatNode/stringFormatNode.cpp.
MStatus setKeyable ( bool  state)

Sets whether this attribute should accept keyframe data.

This should only get called in the initialize call of your node creator. Keyable attributes will be keyed by AutoKey and the Set Keyframe UI. Non-keyable attributes prevent the user from setting keys via the obvious UI provided for keying. Being non-keyable is not a hard block against adding keys to an attribute.

This method changes the default state of a plug. The keyability of a specific plug can be changed using the MPlug::setKeyable method.

If both keyable and writable for an attribute are set to true it will be displayed in the channel box when the node is selected.

Attributes are not keyable by default.

Parameters
[in]statewhether the attribute is to be keyable
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcImport/AlembicNode.cpp, AbcImport/MeshHelper.cpp, AbcImport/NodeIteratorVisitorHelper.cpp, apiMeshShape/apiMeshCreator.cpp, atomImportExport/atomFileUtils.cpp, cgFx/cgfxAttrDef.cpp, cgFx/cgfxShaderNode.cpp, cgFx/cgfxVector.cpp, closestPointOnCurve/closestPointOnCurveNode.cpp, customComponentTagNode/customComponentTagNode.cpp, customImagePlane/customImagePlane.cpp, displacementShader/displacementShader.cpp, dx11Shader/dx11Shader.cpp, dynExprField/dynExprField.cpp, footPrintNode_AnimatedMaterial/footPrintNode_GeometryOverride_AnimatedMaterial.cpp, gameInputDevice/gameInputDevice.cpp, genericAttributeNode/genericAttributeNode.cpp, geometrySurfaceConstraint/geometrySurfaceConstraint.cpp, glslShader/GLSLShader.cpp, hlslShader/hlslShader.cpp, hwPhongShader/hwPhongShader.cpp, interpShader/interpShader.cpp, lambertShader/lambertShader.cpp, lightShader/lightShader.cpp, manipOverride/rockingTransform2.cpp, MayaPluginForSpreticle/spReticleLoc.cpp, meshOpCmd/meshOpNode.cpp, multiCurveNode/multiCurveNode.cpp, offsetNode/offsetNode.cpp, pointOnMeshInfo/pointOnMeshInfoNode.cpp, pointOnSubdNode/pointOnSubdNode.cpp, rockingTransform/rockingTransform.cpp, rockingTransformCheck/rockingTransform.cpp, shadowMatteShader/shadowMatteShader.cpp, shellNode/shellNode.cpp, simpleEvaluationDraw/simpleEvaluationDraw.cpp, simpleEvaluationNode/simpleEvaluationNode.cpp, simplePhysicsEngine/simplePhysicsEngine.cpp, simpleSimulationNode/simpleSimulationNode.cpp, simpleSpring/simpleSpring.cpp, slopeShader/slopeShaderNode.cpp, stringFormatNode/stringFormatNode.cpp, testMTopologyEvaluator/testMTopologyEvaluator.cpp, torusField/torusField.cpp, volumeShader/volumeShader.cpp, vp2BlinnShader/vp2BlinnShader.cpp, weightListNode/weightListNode.cpp, and yTwistNode/yTwistNode.cpp.
MStatus setChannelBox ( bool  state)

Sets whether this attribute should appear in the channel box when the node is selected.

This should only get called in the initialize call of your node creator. Keyable attributes are always shown in the channel box so this flag is ignored on keyable attributes. It is for intended for use on non-keyable attributes which you want to appear in the channel box.

This method changes the default state of a plug. Channel box visibility for a specific plug can be changed using the MPlug::setChannelBox method.

Attributes are not in the channel box by default unless they are keyable.

Parameters
[in]statewhether the attribute is to appear in the channel box
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
simplePhysicsEngine/simplePhysicsEngine.cpp.
MStatus setHidden ( bool  state)

Sets whether this attribute should be hidden from the UI.

This is useful if the attribute is being used for blind data, or if it is being used as scratch space for a geometry calculation (should also be marked non-connectable in that case).

Attributes are not hidden by default.

Parameters
[in]statewhether the attribute is to be hidden
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcImport/AlembicNode.cpp, AbcImport/MeshHelper.cpp, anisotropicShader/anisotropicShader.cpp, apiMeshShape/apiMeshCreator.cpp, backfillShader/backfillShader.cpp, brickShader/brickShader.cpp, cellShader/cellShader.cpp, cgFx/cgfxShaderNode.cpp, checkerShader/checkerShader.cpp, clearcoat.cpp, depthShader/depthShader.cpp, displacementShader/displacementShader.cpp, exampleFalloff/smoothFalloffNode.cpp, fileTexture/fileTexture.cpp, flameShader/flameShader.cpp, footPrintNode_AnimatedMaterial/footPrintNode_GeometryOverride_AnimatedMaterial.cpp, footPrintNode_GeometryOverride/footPrintNode_GeometryOverride.cpp, gameInputDevice/gameInputDevice.cpp, geometrytools.cpp, geomShader/geomShader.cpp, hwPhongShader/hwPhongShader.cpp, interpShader/interpShader.cpp, lambertShader/lambertShader.cpp, lavaShader/lavaShader.cpp, lightShader/lightShader.cpp, MayaPluginForSpreticle/spReticleLoc.cpp, meshOpCmd/meshOpNode.cpp, noiseShader/noiseShader.cpp, onbShader/onbShader.cpp, phongShader/phongShader.cpp, shadowMatteShader/shadowMatteShader.cpp, shiftNode/shiftNode.cpp, simpleNoiseShader/simpleNoiseShader.cpp, simplePhysicsEngine/simplePhysicsEngine.cpp, simpleSimulationNode/simpleSimulationNode.cpp, slopeShader/slopeShaderNode.cpp, solidCheckerShader/solidCheckerShader.cpp, testNobjectNode/testNobjectNode.cpp, testNpassiveNode/testNpassiveNode.cpp, testNsolverNode/testNsolverNode.cpp, testNucleusNode/testNucleusNode.cpp, and volumeShader/volumeShader.cpp.
MStatus setUsedAsColor ( bool  state)

Sets whether this attribute should be presented as a color in the UI.

Parameters
[in]statewhether the attribute is to be presented as a color
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcImport/NodeIteratorVisitorHelper.cpp, cgFx/cgfxAttrDef.cpp, interpShader/interpShader.cpp, lambertShader/lambertShader.cpp, MayaPluginForSpreticle/spReticleLoc.cpp, onbShader/onbShader.cpp, simpleNoiseShader/simpleNoiseShader.cpp, slopeShader/slopeShaderNode.cpp, transformDrawNode/transformDrawNode.cpp, and uiDrawManager/uiDrawManager.cpp.
MStatus setIndeterminant ( bool  state)

Sets whether this attribute is indeterminant.

If an attribute may or may not be used during an evaluation then it is indeterminant. This attribute classification is mainly used on rendering nodes to indicate that some attributes are not always used.

Attributes are not indeterminant by default.

Parameters
[in]statewhether the attribute indeterminant
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
MStatus setRenderSource ( bool  state)

Sets whether this attribute should be used as a render source attribute.

When writing shader plug-ins, it is sometimes useful to be able to modify the sampler info, so upstream shading network can be re- evaluated with different sampler info values.

For example, if a shading node takes a 2D texture as input, the result color of the 2D texture is evaluated at the current sample's UV coordinates. Initializing uvCoords attributes as render source and modifing the U and V values, then setting it as output will modify the sampler info. Re-evaluating the input plug will cause the 2D texture to re-evaluate with the new U and V values, and return a different color to the shading node.

Only valid Maya rendering attributes can be set to render source.

The following code example demonstrates how this is done:

initialize()

...

creates attributes for uvCoord and set them to be render source

u = nAttr.create( "uCoord", "u", MFnNumericData::kFloat, 0.0 ); nAttr.setStorable(false); nAttr.setWritable(true); nAttr.setRenderSource(true); v = nAttr.create( "vCoord", "v", MFnNumericData::kFloat, 0.0 ); nAttr.setStorable(false); nAttr.setWritable(true); nAttr.setRenderSource(true); uv = nAttr.create( "uvCoord", "uv", u, v ); nAttr.setStorable(false); nAttr.setWritable(true); nAttr.setRenderSource(true);

need to have the output uv affect the input uv because we want the new uv values we set to cause other inputs to this node to evaluate

attributeAffects ( uv, uv );

...

compute()

...

get uv coordinates from the sampler

MDataHandle uH = data.inputValue( u, &stat); MDataHandle vH = data.inputValue( v, &stat); float oldU = uH.asFloat(); float oldV = vH.asFloat();

get shading color input at the current sampler's uv coordinates

MDataHandle colorH = data.inputValue( inColor, &stat); MFloatVector color = colorH.asFloatVector(); // color at the sampled uv location

evaluate input color at a different uv location:

set output uv coordinates back to sampler this is only possible because we've set uv to be render source

MDataHandle outUV = data.outputValue( uv ); outUV.set( oldU-0.01, oldV-0.01 );

get newly evaluated inColor at uv(oldU-0.01, oldV-0.01)

any shading node connected to inColor will get uvCoord values as we've supplied. Calling data.inputValue( inColor, &stat) causes it to re-evaluate the network again with the new uvCoord values.

colorH = data.inputValue( inColor, &stat); // evaluate again color = colorH.asFloatVector(); // color at the new uv location

...

outUV.set( oldU, oldV ); // set the values back before we exit

...

Parameters
[in]statewhether the attribute is to be a render source
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
shiftNode/shiftNode.cpp.
MStatus setWorldSpace ( bool  state)

Sets whether this attribute should be treated as worldspace.

Being worldspace indicates the attribute is dependent on the worldSpace transformation of this node, and will be marked dirty by any attribute changes in the hierarchy that affects the worldSpace transformation. The attribute needs to be an array since during instancing there are multiple worldSpace paths to the node & Maya requires one array element per path for worldSpace attributes.

NOTES: 1. Can only be used on array attributes. 2. This property is ignored on non-dag nodes. 3. The attribute should be affected by another attribute or have a connection. Otherwise, the attribute will not get computed and will not get dirty again.

Parameters
[in]statewhether the attribute is to be presented as worldspace
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object or the attribute is not an array
Examples:
footPrintNode/footPrintNode.cpp.
MStatus setAffectsWorldSpace ( bool  state)

Sets whether this attribute should affect worldspace.

NOTES: This property is ignored on non-dag nodes.

Parameters
[in]statewhether the attribute should affect worldspace
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
manipOverride/rockingTransform2.cpp, rockingTransform/rockingTransform.cpp, and rockingTransformCheck/rockingTransform.cpp.
MStatus setUsedAsFilename ( bool  state)

Sets whether this attribute should be presented as a filename in the UI.

Parameters
[in]statewhether the attribute is to be presented as a filename
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcImport/AlembicNode.cpp, dx11Shader/dx11Shader.cpp, glslShader/GLSLShader.cpp, gpuCache/gpuCacheShapeNode.cpp, and sceneAssembly/assemblyReference.cpp.
MStatus setAffectsAppearance ( bool  state)

Sets whether this attribute affects the appearance of the object when rendering in the viewport.

Parameters
[in]statewhether the attribute affects the appearance of the object when rendering in the viewport.
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
cgFx/cgfxAttrDef.cpp, cgFx/cgfxShaderNode.cpp, dx11Shader/dx11Shader.cpp, glslShader/GLSLShader.cpp, hwPhongShader/hwPhongShader.cpp, and vp2BlinnShader/vp2BlinnShader.cpp.
MStatus setProxyAttribute ( bool  state)

Sets whether this attribute is a proxy attribute.

Parameters
[in]statewhether the attribute is a proxy attribute.
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
MStatus setDisconnectBehavior ( MFnAttribute::DisconnectBehavior  behavior)

Sets the disconnection behavior for this attribute.

This determines what happens when a connection to this attribute is deleted. This should only get called in the initialize call of your node creator.

The settings are as follows:

  • kDelete delete the element of the array that was connected. This is only used for array attributes
  • kReset reset the attribute to its default value
  • kNothing leave the attribute set to its last known value

Attributes have a default disconnect behavior of kNothing.

If the kDelete behaviour is set on an array attribute which is a compound, that will only handle the case where the connection is to the parent attribute not to its children. So breaking a connection to an element of the parent (e.g. node.parent[3]) would cause that element to be removed, but breaking a connection to a child (e.g. node.parent[3].child) would leave the element intact, even if it was the last such connection.

To have the parent array element deleted when the last connection to a child is broken, you must set the kDelete behaviour on the connectable children as well.

Parameters
[in]behaviorthe new disconnect behavior
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.cpp.
MStatus setUsesArrayDataBuilder ( bool  state)

Sets whether this attribute uses an array data builder.

If true, then the MArrayDataBuilder class may be used with this attribute to generate its data. If false, MArrayDataHandle::builder will fail.

By default array attributes do not use an array data builder.

Parameters
[in]statewhether the attribute uses an array data builder
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
AbcImport/AlembicNode.cpp, footPrintNode/footPrintNode.cpp, multiCurveNode/multiCurveNode.cpp, slopeShader/slopeShaderNode.cpp, and weightListNode/weightListNode.cpp.
MStatus setInternal ( bool  state)

The function controls an attribute's data storage.

When set to true, the virtual methods MPxNode::setInternalValue() and MPxNode::getInternalValue() are invoked whenever the attribute value is set or queried, respectively. By default, attributes are not internal.

There are two reasons to set an attribute as 'internal'. The first, and simplest, is when you want notification that the attribute has been set, or queried. This allows you to invoke some related action. In this case getInternalValue() and setInternalValue() should return false to indicate that Maya can store the attribute's value in the data block, instead of your own custom structure.

The second use of internal attributes is to store the data in a structure other than the datablock. When MPxNode::setInternalValue() is called, the attribute's data can be transferred into your custom data structure. When getInternalValue( you can return your data. In this case getInternalValue() and setInternalValue() should return true to indicate that Maya should not store the attribute's value in the data block but use your own custom structure instead.

Parameters
[in]statewhether the attribute uses internal data
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
cgFx/cgfxShaderNode.cpp, customImagePlane/customImagePlane.cpp, dx11Shader/dx11Shader.cpp, glslShader/GLSLShader.cpp, gpuCache/gpuCacheShapeNode.cpp, hlslShader/hlslShader.cpp, hwPhongShader/hwPhongShader.cpp, MayaPluginForSpreticle/spReticleLoc.cpp, sceneAssembly/assemblyReference.cpp, and testMTopologyEvaluator/testMTopologyEvaluator.cpp.
MStatus setNiceNameOverride ( const MString localizedName)

Sets the localized string which should be used for this attribute in the UI.

The name given to an attribute when it is created is the name used to refer to it when the scene is written to a file. To ensure that the scene file is readable across all locales it is essential that the attribute have the same name in all locales. So if it's called 'keyLight' in an English locale then it must also be called 'keyLight' in French and Chinese locales.

The setNiceNameOverride() method provides a means for associating a more user-friendly name with the attribute, one which can change to accomodate the user's locale. If such a name is present then Maya will use it instead of the attribute's fixed name when displaying the attribute in various UI elements such as the Channel Box.

Parameters
[in]localizedNameThe name to use for the current locale.
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
dx11Shader/dx11Shader.cpp, and glslShader/GLSLShader.cpp.
bool acceptsAttribute ( const MFnAttribute attr,
MStatus ReturnStatus = NULL 
) const

Returns true if this attribute can accept a connection with the given attribute.

Parameters
[in]attrattribute
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether a connection with that attribute is valid
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool accepts ( MFnData::Type  type,
MStatus ReturnStatus = NULL 
) const

Returns true if this attribute can accept a connection of the given type.

Parameters
[in]typedata type
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether a connection of that type is valid
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
bool accepts ( const MTypeId id,
MStatus ReturnStatus = NULL 
) const

Returns true if this attribute can accept a connection of the given type.

Parameters
[in]iddata type id
[out]ReturnStatusreturn status
Returns
A boolean value indicating whether a connection of that type is valid
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
MObject parent ( MStatus ReturnStatus = NULL) const

Get the parent of this attribute, if it has one.

Parameters
[out]ReturnStatusreturn status
Returns
The parent attribute
Status Codes:
  • MS::kSuccess operation successful
  • MS::kNotFound the attribute does not have a parent
  • MS::kFailure function set does not have a valid object
MString name ( MStatus ReturnStatus = NULL) const

Returns the long name of the attribute.

If the attribute has no long name then its short name is returned.

Parameters
[out]ReturnStatusThe status of the resulting operation.
Returns
The name of the attribute.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
cgFx/cgfxAttrDef.cpp, and getAttrAffectsCmd/getAttrAffectsCmd.cpp.
MString shortName ( MStatus ReturnStatus = NULL) const

Returns the short name of the attribute.

If the attribute has no short name then its long name is returned.

Parameters
[out]ReturnStatusThe status of the resulting operation.
Returns
The name of the attribute.
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
MString getAddAttrCmd ( bool  useLongName = false,
MStatus status = NULL 
) const

Returns a string containing the addAttr command which would be required to recreate the attribute on a node.

The command includes the terminating semicolon and is formatted as if for use with a selected node, meaning that it contains no node name.

To get the addAttr commands for a compound attribute and its children, use MFnCompoundAttribute::getAddAttrCmds.

Parameters
[in]useLongNameif true, use the attribute's long name rather than its short name
[in]statusThe status of the resulting operation. addAttr command
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
  • MS::kInvalidParameter function set is not bound to an attribute
MStatus addToCategory ( const MString category)

Add the attribute to the named category.

Attributes can be associated with different categories to facilitate grouping related concepts. For example, these categories could be queried at runtime to customize the UI.

Parameters
[in]categoryNew category to which the attribute is to be added
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object
Examples:
cgFx/cgfxAttrDef.cpp, and dx11Shader/dx11Shader.cpp.
MStatus removeFromCategory ( const MString category)

Remove the attribute from the named category.

Presumes membership in the named category and fails if that's not true.

Parameters
[in]categoryCategory from which the attribute is to be removed
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kNotFound attribute was not in category
  • MS::kFailure this function set does not have a valid attribute object
bool hasCategory ( const MString category) const

Check to see if the attribute belongs to the named category.

Matching is done solely on the string so multiple categories with the same name will not be unique.

Parameters
[in]categoryCategory to check for attribute membership
Returns
True if the attribute belongs to that category
MStatus getCategories ( MStringArray categories) const

Get all of the categories to which this attribute belongs.

Parameters
[in]categoriesAn MStringArray which will be overwritten with the categories associated with this attribute.
Returns
Return status
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure this function set does not have a valid attribute object

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