MPlug Class Reference
[OpenMaya - API module for common classes]

#include <MPlug.h>

List of all members.


Detailed Description

Create and Access dependency node plugs.

MPlug provides methods for creating plugs, and accessing the plugs' dependency node and attributes.

A plug is a point on a dependency node where a particular attribute can be connected. In simple cases the plug and attribute are equivalent. When you have array attributes, however, the plug is more specific in that it indicates which of the array elements is to be connected.

There are two main types of plugs: networked plugs and non-networked plugs. Non-networked plugs can be considered user plugs as they are created by users and belong to users. Networked plugs can be considered dependency node plugs as they are part of the dependency graph and can only be referenced by users.

In every dependency node there is a network or "tree" of plugs indicating connections that have been made to attributes of the node. The plugs in this tree are known as networked plugs as they belong to the dependency node's network.

Non-networked plugs are plugs that you can create in order to establish a new connection to an attribute, or to get or set a value on an attribute. When a connection is made using these plugs, a networked version of the plug is created and added to the dependency nodes network.

A networked plug cannot be explicitly created. They are created when a connection is established for some attribute of the node. Since the allocation of networked plugs is managed exclusively by Maya, a plugin should never reference a networked plug after changes are made to the DG. Instead, use a non-networked version of the plug, or get a new reference to the networked plug.

All a non-networked plug knows is how to uniquely describe the attribute that it references, in fact the purpose of a non-networked plug is to specify, without ambiguity, an attribute of a dependency node. A non-networked plug contains an array of array indices that plot the path from the root plug to this plug.

For simple attributes the plug and attribute are equivalent. Compound attributes are also unambiguous. A plug that refers to an array attribute, however, is more complex as it can refer to the array plug or an element plug in the array.

Several methods are provided for navigating the plug tree. The child method can be used to retrieve the child plugs of a compound plug. The elementByLogicalIndex and elementByPhysicalIndex methods can be used to retrieve the element plugs of an array plug. The parent and array methods traverse the tree in the opposite direction: parent retrieves a compound plug from a child plug, and array retrieves an array plug from an element plug.

Since connections to arrays are sparse, element plugs have both logical and physical indexes. The logical indexes are used by MEL, and are sparse. Physical indexes, on the other hand, are not sparse. It is guaranteed that the physical indexes will range from 0 to numElements() - 1. Using the physical indexes, iterating over the element plugs in an array is easy:

       // See note below on numElements() method
       for (i = 0; i < arrayPlug.numElements (); i++)
       {
           MPlug elementPlug = arrayPlug [i];
                   unsigned int logicalIndex = elementPlug.logicalIndex();
           // ...
       }

This is equivalent to calling elementByPhysicalIndex since the bracket operator uses physical indexes.

The ancestry of a plug is the tree above the plug: any parents or arrays which this plug belongs to. The selectAncestorLogicalIndex method provides quick access to element plugs without walking the plug tree. A plug does not need to exist in the datablock or plug tree in order to be constructed using selectByLogicalIndex, but once a value is requested or set on the plug, it will be added to the datablock if it was not there already. For example:

        MPlug plug(node,attribute);
        // See note below on numElements() method
        unsigned int count = plug.numElements();
        if (0 == count) {
            plug.selectAncestorLogicalIndex(0,attribute);
                plug.setValue(setVal);
                count = plug.numElements(); // count will now be 1 since we added a value

            plug.selectAncestorLogicalIndex(10,attribute);
                MObject getVal;
                plug.getValue(getVal);
                count = plug.numElements(); // count will now be 2 since we asked for a value
        }

Once a value has been added to an array plug, it will usually remain in the datablock as long as the scene is open. The exception is for attributes that have their disconnect behavior set to kDelete; data for these attributes will be deleted when their connection is broken. When a file is saved, only array values that are not at their default values will be written out. Therefore, the number of elements in an array plug may change when the file is read in again.

Note:
The numElements() call for array plugs returns a value based on the information in the datablock. It is possible to have un-evaluated connected items being excluded from the count since these items are not yet in the datablock. In this case, the numElements() method will return the correct answer if the evaluateNumElements() call is made first. But this cannot be done in the compute() method of a node.
Examples:

affectsNode.cpp, animCubeNode.cpp, animExportUtil.cpp, animInfoCmd.cpp, anisotropicShader.cpp, apiMeshCreator.cpp, apiMeshCreator.h, apiMeshShape.cpp, apiMeshShape.h, arcLenNode.cpp, backfillShader.cpp, blindComplexDataCmd.cpp, blindDataMesh.cpp, blindDataMesh.h, blindDataShader.cpp, blindDataShader.h, blindDoubleDataCmd.cpp, brickShader.cpp, buildRotationNode.cpp, cellShader.cpp, cgfxAttrDef.cpp, cgfxAttrDef.h, cgfxShaderNode.cpp, cgfxShaderNode.h, cgfxVector.cpp, cgfxVector.h, checkerShader.cpp, circleNode.cpp, clearcoat.cpp, closestPointCmd.cpp, closestPointOnCurveCmd.cpp, closestPointOnCurveNode.cpp, closestPointOnCurveNode.h, clothPaintAttrCmd.cpp, componentScaleManip.cpp, compositingShader.cpp, contrastShader.cpp, createClipCmd.cpp, curvedArrowsNode.cpp, customAttrManip.cpp, customImagePlane.cpp, cvColorNode.cpp, cvColorShader.cpp, D3DResourceManager.cpp, D3DViewportRenderer.cpp, dagPoseInfoCmd.cpp, depthShader.cpp, displacementShader.cpp, dynExprField.cpp, dynExprField.h, exampleMRampAttribute.cpp, exportJointClusterDataCmd.cpp, filteredAsciiFile.cpp, findFileTexturesCmd.cpp, findTexturesPerPolygonCmd.cpp, flameShader.cpp, footPrintManip.cpp, footPrintNode.cpp, fullLoftNode.cpp, gammaShader.cpp, genericAttributeNode.cpp, geometrySurfaceConstraint.cpp, geometrySurfaceConstraint.h, geomShader.cpp, GLSLShaderNode.cpp, GLSLShaderNode.h, hlslShader.cpp, hlslShader.h, hwAnisotropicShader_NV20.cpp, hwColorPerVertexShader.cpp, hwDecalBumpShader_NV20.cpp, hwDecalBumpShader_NV20.h, hwPhongShader.cpp, hwPhongShader.h, hwPhongShaderBehavior.cpp, hwPhongShaderBehavior.h, hwReflectBumpShader_NV20.cpp, hwReflectBumpShader_NV20.h, hwRefractReflectShader_NV20.cpp, hwRefractReflectShader_NV20.h, hwToonShader_NV20.cpp, hwToonShader_NV20.h, hwUnlitShader.cpp, hwUnlitShader.h, interpShader.cpp, intersectCmd.cpp, jitterNode.cpp, lambertShader.cpp, latticeNoise.h, latticeNoiseNode.cpp, lavaShader.cpp, lepTranslator.cpp, lightShader.cpp, lockEvent.cpp, maTranslator.cpp, meshOpCmd.cpp, meshOpNode.cpp, meshOpNode.h, mixtureShader.cpp, motionTraceCmd.cpp, moveManip.cpp, MTextureCache.cpp, multiCurveNode.cpp, narrowPolyViewer.h, nodeInfoCmd.cpp, nodeMessageCmd.cpp, noiseShader.cpp, ownerEmitter.cpp, ownerEmitter.h, particleAttrNode.cpp, particleAttrNode.h, phongShader.cpp, pluginMain.cpp, pnTrianglesNode.cpp, pnTrianglesNode.h, pointOnMeshCmd.cpp, pointOnMeshInfoNode.cpp, pointOnMeshInfoNode.h, pointOnSubdNode.cpp, pointOnSubdNode.h, polyExporter.cpp, polyModifierCmd.cpp, polyModifierCmd.h, polyTrgNode.cpp, polyWriter.cpp, quadricShape.cpp, renderAccessNode.cpp, rockingTransform.cpp, rockingTransform.h, rockingTransformCheck.cpp, rockingTransformCheck.h, rotateManip.cpp, ShadingConnection.cpp, ShadingConnection.h, shadowMatteShader.cpp, shellNode.cpp, shiftNode.cpp, simpleEmitter.cpp, simpleEmitter.h, simpleFluidEmitter.cpp, simpleFluidEmitter.h, simpleLoftNode.cpp, simpleSpring.cpp, simpleSpring.h, sineNode.cpp, slopeShaderBehavior.cpp, slopeShaderBehavior.h, slopeShaderNode.cpp, slopeShaderNode.h, solidCheckerShader.cpp, splitUVCmd.cpp, splitUVNode.cpp, splitUVNode.h, squareScaleManipContext.cpp, stringFormatNode.cpp, surfaceBumpManip.cpp, sweptEmitter.cpp, sweptEmitter.h, swissArmyManip.cpp, testNobjectNode.cpp, testNobjectNode.h, testNucleusNode.cpp, testNucleusNode.h, torusField.cpp, torusField.h, transCircleNode.cpp, volumeShader.cpp, and weightListNode.cpp.


Public Types

enum  MValueSelector { kAll, kNonDefault, kChanged, kLastAttrSelector }
 Which values to generate setAttr commands for. More...
enum  FreeToChangeState { kFreeToChange = 0, kNotFreeToChange, kChildrenNotFreeToChange }
 Plug state returned by isFreeToChange. More...

Public Member Functions

 MPlug ()
 MPlug (const MPlug &in)
 MPlug (const MObject &node, const MObject &attribute)
 ~MPlug ()
MStatus setAttribute (MObject &attribute)
MObject attribute (MStatus *ReturnStatus=NULL) const
MObject node (MStatus *ReturnStatus=NULL) const
MString name (MStatus *ReturnStatus=NULL) const
MString partialName (bool includeNodeName=false, bool includeNonMandatoryIndices=false, bool includeInstancedIndices=false, bool useAlias=false, bool useFullAttributePath=false, bool useLongNames=false, MStatus *ReturnStatus=NULL) const
MStatus getSetAttrCmds (MStringArray &cmds, MValueSelector valueSelector=kAll, bool useLongNames=false)
bool isNetworked (MStatus *ReturnStatus=NULL) const
bool isArray (MStatus *ReturnStatus=NULL) const
bool isElement (MStatus *ReturnStatus=NULL) const
bool isCompound (MStatus *ReturnStatus=NULL) const
bool isChild (MStatus *ReturnStatus=NULL) const
bool isProcedural (MStatus *ReturnStatus=NULL) const
unsigned int logicalIndex (MStatus *ReturnStatus=NULL) const
MStatus selectAncestorLogicalIndex (unsigned int index, const MObject &attribute=MObject::kNullObj)
unsigned int getExistingArrayAttributeIndices (MIntArray &indices, MStatus *ReturnStatus=NULL)
unsigned int numElements (MStatus *ReturnStatus=NULL) const
unsigned int evaluateNumElements (MStatus *ReturnStatus=NULL)
unsigned int numChildren (MStatus *ReturnStatus=NULL) const
unsigned int numConnectedElements (MStatus *ReturnStatus=NULL) const
unsigned int numConnectedChildren (MStatus *ReturnStatus=NULL) const
MPlug child (MObject &attr, MStatus *ReturnStatus=NULL) const
MPlug child (unsigned int index, MStatus *ReturnStatus=NULL) const
MPlug parent (MStatus *ReturnStatus=NULL) const
MPlug array (MStatus *ReturnStatus=NULL) const
MPlug elementByLogicalIndex (unsigned int logicalIndex, MStatus *ReturnStatus=NULL) const
MPlug elementByPhysicalIndex (unsigned int physicalIndex, MStatus *ReturnStatus=NULL) const
MPlug connectionByPhysicalIndex (unsigned int physicalIndex, MStatus *ReturnStatus=NULL) const
bool connectedTo (MPlugArray &array, bool asDst, bool asSrc, MStatus *ReturnStatus=NULL) const
bool isConnected (MStatus *ReturnStatus=NULL) const
bool isKeyable (MStatus *ReturnStatus=NULL) const
MStatus setKeyable (bool keyable)
bool isLocked (MStatus *ReturnStatus=NULL) const
MStatus setLocked (bool locked)
bool isChannelBoxFlagSet (MStatus *ReturnStatus=NULL) const
MStatus setChannelBox (bool channelBox)
bool isCachingFlagSet (MStatus *ReturnStatus=NULL) const
MStatus setCaching (bool caching)
bool isNull (MStatus *ReturnStatus=NULL) const
MString info (MStatus *ReturnStatus=NULL) const
bool isFromReferencedFile (MStatus *ReturnStatus=NULL) const
bool isDynamic (MStatus *ReturnStatus=NULL) const
bool isIgnoredWhenRendering (MStatus *ReturnStatus=NULL) const
MPlug::FreeToChangeState isFreeToChange (bool checkParents=true, bool checkChildren=true, MStatus *ReturnStatus=NULL) const
MDataHandle constructHandle (MDataBlock &) const
void destructHandle (MDataHandle &) const
MStatus getValue (MObject &val, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (double &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (float &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (int &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (short &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (bool &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (MDistance &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (MAngle &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (MTime &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (char &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus getValue (MString &, MDGContext &ctx=MDGContext::fsNormal) const
 NO SCRIPT SUPPORT.
MStatus setValue (MObject &val)
 NO SCRIPT SUPPORT.
MStatus setValue (MPxData *data)
 NO SCRIPT SUPPORT.
MStatus setValue (MDataHandle &handle)
 NO SCRIPT SUPPORT.
MStatus setValue (double)
 NO SCRIPT SUPPORT.
MStatus setValue (float)
 NO SCRIPT SUPPORT.
MStatus setValue (int)
 NO SCRIPT SUPPORT.
MStatus setValue (short)
 NO SCRIPT SUPPORT.
MStatus setValue (bool)
 NO SCRIPT SUPPORT.
MStatus setValue (MDistance &)
 NO SCRIPT SUPPORT.
MStatus setValue (MAngle &)
 NO SCRIPT SUPPORT.
MStatus setValue (MTime &)
 NO SCRIPT SUPPORT.
MStatus setValue (char)
 NO SCRIPT SUPPORT.
MStatus setValue (const MString &)
 NO SCRIPT SUPPORT.
MStatus setValue (const char *)
 NO SCRIPT SUPPORT.
MObject asMObject (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
double asDouble (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
float asFloat (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
int asInt (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
short asShort (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
bool asBool (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
MDistance asMDistance (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
MAngle asMAngle (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
MTime asMTime (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
char asChar (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
MString asString (MDGContext &ctx=MDGContext::fsNormal, MStatus *ReturnStatus=NULL) const
MStatus setMObject (MObject &val)
MStatus setMPxData (MPxData *data)
MStatus setMDataHandle (MDataHandle &handle)
MStatus setDouble (double)
MStatus setFloat (float)
MStatus setInt (int)
MStatus setShort (short)
MStatus setBool (bool)
MStatus setMDistance (MDistance &)
MStatus setMAngle (MAngle &)
MStatus setMTime (MTime &)
MStatus setChar (char)
MStatus setString (const MString &)
MPlugoperator= (const MPlug &other)
MPlug operator[] (unsigned int physicalIndex) const
bool operator== (const MPlug &other) const
bool operator== (const MObject &other) const
bool operator!= (const MPlug &other) const
bool operator!= (const MObject &other) const
MStatus setNumElements (unsigned int)
MPlug operator[] (MObject &attr) const
 NO SCRIPT SUPPORT.
 operator MObject () const
 NO SCRIPT SUPPORT.
bool operator! () const
 NO SCRIPT SUPPORT.

Member Enumeration Documentation

Which values to generate setAttr commands for.

Enumerator:
kAll  All values.
kNonDefault  Non default values.
kChanged  Changed values.
kLastAttrSelector  Last value, for counting.

Plug state returned by isFreeToChange.

Enumerator:
kFreeToChange  All tested plugs are free to change.
kNotFreeToChange  Some of the tested plugs are not free to change.
kChildrenNotFreeToChange  Some of the children are not free to change.


Constructor & Destructor Documentation

MPlug::MPlug (  ) 

Constructor. Creates an empty plug.

MPlug::MPlug ( const MPlug other  ) 

Copy constructor. Duplicates the given plug.

Parameters:
[in] other Plug to be copied.

MPlug::MPlug ( const MObject node,
const MObject attribute 
)

Constructor. Creates a new plug for the specified attribute and dependency node.

The new plug can be used to establish or remove a connection to the attribute it references. The plug can also be used to query or set the value of the attribute.

This constructor will only create non-networked plugs. A networked version of this plug is automatically created and added to the dependency node's network when a connection to this plug is established.

Parameters:
[in] node the dependency node this plug belongs to
[in] attribute the attribute this plug refers to

MPlug::~MPlug (  ) 

Destructor.


Member Function Documentation

MStatus MPlug::setAttribute ( MObject attribute  ) 

This method is a convenience routine to allow quick movement between attributes on a single node. If the current plug is a networked plug, it becomes a new non-networked plug referring to the requested attribute. If the current plug is a non-networked plug, it is changed to refer to the requested attribute.

The passed attribute must be the attribute of a plug on the current node.

Parameters:
[in] attribute attribute to change the plug to
Returns:
Status code
Status Codes:
Examples:

MObject MPlug::attribute ( MStatus ReturnStatus = NULL  )  const

This method returns the attribute that this plug refers to.

Parameters:
[out] ReturnStatus Status Code
Returns:
The attribute that this plug refers to.
Status Codes:
Examples:

MObject MPlug::node ( MStatus ReturnStatus = NULL  )  const

Returns the dependency node that this plug belongs to.

Parameters:
[out] ReturnStatus Status Code
Returns:
A pointer to this plug's dependency node.
Status Codes:
Examples:

MString MPlug::name ( MStatus ReturnStatus = NULL  )  const

Returns the name of this plug in the form "<i>nodeName</i>.<i>attributeName</i>".

Parameters:
[out] ReturnStatus return status
Returns:
The name of this node
Status Codes:
Examples:

MString MPlug::partialName ( bool  includeNodeName = false,
bool  includeNonMandatoryIndices = false,
bool  includeInstancedIndices = false,
bool  useAlias = false,
bool  useFullAttributePath = false,
bool  useLongNames = false,
MStatus ReturnStatus = NULL 
) const

By default, this method returns the shortest possible name for the plug, but its parameters can be used to add parts back in.

Parameters:
[in] includeNodeName If true, then the plug's node name is prefixed to the name of the plug, with a dot separating it from the attribute name.
If false, then just the attribute name is returned. (default: false)

Parameters:
[in] includeNonMandatoryIndices If the plug's attribute is a non-instanced element of a multi which is NOT marked as indexMatters, then setting this parameter true will cause its index to be included in the returned string anyway. (default: false)
If the attribute is marked as indexMatters then its array index will be included regardless of the setting of this parameter.

If the attribute is instanced then it is not affected by this parameter. See the next parameter instead.

Parameters:
[in] includeInstancedIndices If the plug's attribute is an element of an instanced multi, then setting this parameter true will cause the array index to be included in the returned string. For example, if you are planning to append the returned plug name to a node's dagPath, then the instance index is unnecessary as it can be determined from the dagPath. (default: false)
[in] useFullAttributePath Normally, the plug's attribute path is compressed so that any compound ancestors which do not serve to uniquely identify the plug are removed. Setting this parameter true will cause the full attribute path to be used. (default: false)
[in] useAlias Display aliased name if alias exists. (default: false)
[in] useLongNames Normally, short attribute names are used. Setting this true will cause long names to be used. (default: false)
[out] ReturnStatus Return status.
Returns:
The name of the plug.
Status Codes:
Examples:

MStatus MPlug::getSetAttrCmds ( MStringArray cmds,
MPlug::MValueSelector  valueSelector = kAll,
bool  useLongNames = false 
)

Returns an array of strings containing setAttr commands for this plug and all of its descendent plugs.

Parameters:
[out] cmds Array of strings in which the setAttr commands are to be returned.
[in] valueSelector kAll - return setAttr commands for the plug and its children, regardless of their values.
kNonDefault - only return setAttr commands for the plug or its children if they are not at their default values.

kChanged - for nodes from referenced files, setAttr commands are only returned if the plug or one of its children has changed since its file was loaded. For all other nodes, the behaviour is the same a kNonDefault.

Note that if the plug is compound and one of its children has changed, then setAttrs will be generated for *all* of its children, even those which have not changed.

The default is kAll.

Parameters:
[in] useLongNames Normally, the returned commands will use the short names for flags and attributes. If this parameter is true then their long names will be used instead. The default is false.
Returns:
Status code
Status Codes:

bool MPlug::isNetworked ( MStatus ReturnStatus = NULL  )  const

This method determines if the plug is networked or non-networked.

Networked plugs are part of a dependency node network and define points where connections have been made to the nodes attributes.

Non-networked plugs are user created plugs that are used to refer to an attribute of a node so that it can be connected. If the attribute that the plug refers to has been connected then there will also be a corresponding networked plug.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true
  • false
Status Codes:

bool MPlug::isArray ( MStatus ReturnStatus = NULL  )  const

This method determines if the plug is an array plug. Array plugs refer to array attributes and contain element plugs.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true
  • false
Status Codes:
Examples:

bool MPlug::isElement ( MStatus ReturnStatus = NULL  )  const

This method determines if the plug is an element plug. Element plugs refer to array attributes and are members of array plugs.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true
  • false
Status Codes:

bool MPlug::isCompound ( MStatus ReturnStatus = NULL  )  const

This method determines if the plug is a compound plug. Compound plugs refer to compound attributes and have child plugs.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true
  • false
Status Codes:
Examples:

bool MPlug::isChild ( MStatus ReturnStatus = NULL  )  const

This method determines if the plug is a child plug. A child plug's parent is always a compound plug.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true
  • false
Status Codes:
Examples:

bool MPlug::isProcedural ( MStatus ReturnStatus = NULL  )  const

This method determines if the plug is a procedural plug. A procedural plug is one which is created by Maya's internal procedures or by the nodes themselves and which should not be saved to or restored from files.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true
  • false
Status Codes:
Examples:

unsigned int MPlug::logicalIndex ( MStatus ReturnStatus = NULL  )  const

Returns the logical index of the element this plug refers to. The logical index is a sparse index, equivalent to the array index used in MEL.

This plug must be an element plug, and may be either networked or non-networked.

Parameters:
[out] ReturnStatus Status Code
Returns:
The logical array index of the element this plug refers to
Status Codes:
  • MS::kSuccess The operation succeeded
  • MS::kFailure Object error - no plug
  • MS::kInvalidDataType This plug is not an element plug
Examples:

MStatus MPlug::selectAncestorLogicalIndex ( unsigned int  index,
const MObject attribute = MObject::kNullObj 
)

This method is a convenience routine to allow quick iteration and construction of plugs with array plugs in their ancestry. It selects a plug into the current object by changing an ancestor array's logical index.

The passed attribute must be either the attribute of the current plug, or the attribute of an ancestor's plug. It must be an array attribute. By default, it refers to the attribute of the current plug.

If the passed attribute is the attribute of this plug, then this plug will change to refer to its indexth element plug.

For example, consider the following attribute tree. The topmost attribute is a compound attribute "in". It consists of two children: an enum attribute "operation" and a typed attribute "value". Both "value" and "in" are array attributes. To iterate through all of the values, you could write a loop like this:

        MPlug inPlug (node, inAttribute);
        MPlug valuePlug (node, valueAttribute);
        MPlug plug (node, valueAttribute);
        for (i = 0; i < inPlug.numElements (); i++)
        {
                valuePlug.selectAncestorLogicalIndex (i, inAttribute);
            (for j = 0; j < valuePlug.numElements (); j++)
                {
                    plug.selectAncestorLogicalIndex (i, inAttribute);
                    plug.selectAncestorLogicalIndex (j, valueAttribute);
                        // ...
                }
        }

This method is only valid for non-networked plugs since networked plugs are part of a dependency node and can only be modified by making or breaking connections.

Parameters:
[in] index index value to be set
[in] attribute array attribute whose index will be changed
Returns:
Status code
Status Codes:
Examples:

unsigned int MPlug::getExistingArrayAttributeIndices ( MIntArray indices,
MStatus ReturnStatus = NULL 
)

This method will return a list of the logical indices of the elements in an array attribute that are either connected or have had their value set. This method is useful when the logical indices of connected/set elements are sparse.

Parameters:
[in] indices A list to store the logical indices of the set/connected elements.
[out] ReturnStatus Status Code
Returns:
The number of set/connected elements
Status Codes:

unsigned int MPlug::numElements ( MStatus ReturnStatus = NULL  )  const

Return the total number of elements in the datablock of this array plug. The return count will include all existing non-connected elements plus connected elements if they have been evaluated. It will not include connected elements that have not yet been placed into the datablock. The method MPlug::evaluateNumElements can be used in the sitution where you want an accurate count that includes all connected elements.

This method is only valid for array plugs, as no other plugs have elements.

Parameters:
[out] ReturnStatus Status Code
Returns:
Total number of elements
Status Codes:
  • MS::kSuccess The count was successfully returned
  • MS::kFailure The plug is not an array plug or does not contain a valid node or attribute
Examples:

unsigned int MPlug::evaluateNumElements ( MStatus ReturnStatus = NULL  ) 

Return the total number of elements in the datablock of this array plug. The return count will include both connected and non-connected elements, and will perform an evaluate in order to make sure that the datablock is as up-to-date as possible since some nodes do not place array elements into the datablock until the attribute is evaluated.

Because this method performs an evaluate, it should not be called from within the compute of a node. Instead, if you want to know the number of elements in an array plug while in a compute, use either MDataBlock::inputArrayValue or MDataBlock::outputArrayValue because they are more efficient and will not result in recursion.

This method is only valid for array plugs, as no other plugs have elements.

Parameters:
[out] ReturnStatus Status Code
Returns:
Total number of elements
Status Codes:
  • MS::kSuccess The count was successfully returned
  • MS::kFailure The plug is not an array plug or does not contain a valid node or attribute

unsigned int MPlug::numChildren ( MStatus ReturnStatus = NULL  )  const

Return the total number of children of this compound plug.

This method is only valid for networked plugs as non-networked plugs contain no information about their children. If this plug is non-networked then a networked version of the plug will be used. If a networked plug does not exist then 0 will be returned.

This method is also only valid for compound plugs or the root plug, since no other plugs have children.

Parameters:
[out] ReturnStatus Status Code
Returns:
Total number of children
Status Codes:
Examples:

unsigned int MPlug::numConnectedElements ( MStatus ReturnStatus = NULL  )  const

Return the total number of connected element plugs belonging to this array plug.

This method is only valid for networked plugs as non-networked plugs contain no information about their children. If this plug is non-networked then a networked version of the plug will be used. If a networked plug does not exist then 0 will be returned.

This method is also only valid for array plugs, as no other plugs have elements.

Parameters:
[out] ReturnStatus Status Code
Returns:
Total number of elements
Status Codes:

unsigned int MPlug::numConnectedChildren ( MStatus ReturnStatus = NULL  )  const

Return the number of children of this plug that are connected in the dependency graph.

This method is only valid for networked plugs as non-networked plugs contain no information about their children. If this plug is non-networked then a networked version of the plug will be used. If a networked plug does not exist then 0 will be returned.

This method is only valid for compound plugs, since no other plugs have children.

Parameters:
[out] ReturnStatus Status Code
Returns:
Total number of children
Status Codes:
  • MS::kSuccess The count was successfully returned
  • MS::kFailure Object error
  • MS::kInvalidDataType This is not a compound plug

MPlug MPlug::child ( MObject obj,
MStatus ReturnStatus = NULL 
) const

Returns a plug to a given attribute that is a child of this plug. This method is only valid for compound plugs.

Parameters:
[in] obj The child attribute.
Returns:
The child plug
Status Codes:
Examples:

MPlug MPlug::child ( unsigned int  index,
MStatus ReturnStatus = NULL 
) const

Returns a plug to a given attribute that is a child of this plug. This method is only valid for compound plugs.

Parameters:
[in] index The index of the plug to be found
Returns:
The child plug
Status Codes:

MPlug MPlug::parent ( MStatus ReturnStatus = NULL  )  const

MPlug MPlug::array ( MStatus ReturnStatus = NULL  )  const

Returns the array to which this element plug belongs. This method is only valid for networked element plugs.

Parameters:
[out] ReturnStatus Status Code
Returns:
The array of this plug.
Status Codes:

MPlug MPlug::elementByLogicalIndex ( unsigned int  index,
MStatus ReturnStatus = NULL 
) const

This method will find and return a plug with the given logical index. The logical index is the sparse array index used in MEL scripts. If a plug does not exist at the given Index, Maya will create a plug at that index. This is not the case with elementByPhysicalIndex(). If needed, elementByLogicalIndex can be used to expand an array plug on a node. It is important to note that Maya assumes that all such plugs serve a purpose and it will not free non-networked plugs that result from such an array expansion.

The returned plug may or may not be connected.

Parameters:
[in] index The index of the plug to be found
[out] ReturnStatus Status Code
Returns:
A plug with the given index
Status Codes:
  • MS::kSuccess a plug for the given index was successfully returned
  • MS::kFailure Could not get a plug for the given index
Examples:

MPlug MPlug::elementByPhysicalIndex ( unsigned int  index,
MStatus ReturnStatus = NULL 
) const

This method will find and return a plug with the given physical index. The index can range from 0 to numElements() - 1. This function is particularly useful for iteration through the element plugs of an array plug. It is equivalent to operator [] (int) This method is only valid for array plugs.

If the returned plug is networked, the networked plug will be returned. Otherwise, a non-networked plug will be returned.

Parameters:
[in] index The physical array index of the plug to be found
[out] ReturnStatus Status Code
Returns:
A plug with the given index
Status Codes:
  • MS::kSuccess a plug for the given index was successfully returned
  • MS::kFailure Could not get a plug for the given index
Examples:

MPlug MPlug::connectionByPhysicalIndex ( unsigned int  index,
MStatus ReturnStatus = NULL 
) const

This method will find and return a connected plug with the given physical index for its connection. The index can range from 0 to numConnectedElements() - 1. This method varies from elementByPhysicalIndex in that elementByPhysicalIndex will return plugs pointing to all existing data in the datablock regardless of whether the plug is connected or not.

This method is only valid for array plugs.

Parameters:
[in] index The physical array index of the plug to be found
[out] ReturnStatus Status Code
Returns:
A plug with the given index
Status Codes:
  • MS::kSuccess a plug for the given index was successfully returned
  • MS::kFailure Could not get a plug for the given index

bool MPlug::connectedTo ( MPlugArray array,
bool  asDst,
bool  asSrc,
MStatus ReturnStatus = NULL 
) const

This method finds all of the plugs that this plug is connected with. This method will always produce the networked version of the connected plugs.

Parameters:
[in] array Location for storing connected plugs (allocated by the caller)
[in] asDst Check connections with this plug as destination. If there are such connections, put them in array.
[in] asSrc Check connections with this plug as source. If there are such connections, put them in array.
[out] ReturnStatus Status Code
Returns:
  • true If the plug has connections as either source or destination. Note that the array is filled in only with the type of connecting plugs requested by asSrc and asDst. Therefore, the method could return true while the array has nothing in it if, for example, the plug has connections as source but the user passes asSrc = false to the method. The parameters asSrc and asDst have no effect on the boolean return value. Setting one true and one false and then checking the length of the array after calling this method is a way to determine whether the connections are source or destination.
  • false If this plug has no connections
Status Codes:
Examples:

bool MPlug::isConnected ( MStatus ReturnStatus = NULL  )  const

Determines if this plug is connected to one or more plugs.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true If this plug is connected to another plug
  • false If this plug is not connected to another plug
Status Codes:
Examples:

bool MPlug::isKeyable ( MStatus ReturnStatus = NULL  )  const

Determines if this plug is keyable. The default keyability of a plug is determined by its attribute, and can be retrieved using MFnAttribute::isKeyable. Keyable plugs will be keyed by AutoKey and the Set Keyframe UI. Non-keyable plugs 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.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true If this plug is keyable
  • false If this plug is not keyable
Status Codes:

MStatus MPlug::setKeyable ( bool  keyable  ) 

This overrides the default keyability of a plug set with MFnAttribute::setKeyable. Keyable plugs will be keyed by AutoKey and the Set Keyframe UI. Non-keyable plugs 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.

Parameters:
[in] keyable True if this plug should be keyable
Returns:
Status code
Status Codes:

bool MPlug::isLocked ( MStatus ReturnStatus = NULL  )  const

Determines the locked state of this plug's value. A plug's locked state determines whether or not the plug's value can be changed.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true If this plug's value is locked
  • false If this plug's value is not locked
Status Codes:
Examples:

MStatus MPlug::setLocked ( bool  locked  ) 

Sets the locked state for this plug's value. A plug's locked state determines whether or not the plug's value can be changed.

Parameters:
[in] locked True if this plug's value is to be locked
Returns:
Status code
Status Codes:

bool MPlug::isChannelBoxFlagSet ( MStatus ReturnStatus = NULL  )  const

Returns true if this plug or its 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.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true channel box flag has been set
  • false channel box flag has not been set
Status Codes:

MStatus MPlug::setChannelBox ( bool  inChannelBox  ) 

Sets whether this plug is displayed in the channel box. This overrides the default display of a plug set with MFnAttribute::setChannelBox. Keyable attributes are always shown in the channel box so this flag is ignored on keyable plugs.

Parameters:
[in] inChannelBox True if this plug should be displayed in the channel box
Returns:
Status code
Status Codes:

bool MPlug::isCachingFlagSet ( MStatus ReturnStatus = NULL  )  const

Returns true if this plug or its attribute has its caching flag set.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true caching flag has been set
  • false caching flag has not been set
Status Codes:

MStatus MPlug::setCaching ( bool  isCaching  ) 

Sets whether this plug is cached internally. Note: turning caching on for a plug will force the plug to become networked. Network plugs take longer to look up in the DG; therefore you should only make a plug cached only if you are certain that the network plug look-up will take less than the saved evaluation cost.

Not all plugs can be made cached (or un-cached). If the attribute is defined to be cached, then you cannot uncache the attribute. As well, you cannot define caching on element plugs.

Parameters:
[in] isCaching True if this plug should be cached
Returns:
Status code
Status Codes:
  • MS::kSuccess Successful completion
  • MS::kFailure Object error
  • MS::kInvalidDataType Plug is a multi or plug is marked permanently cached.

bool MPlug::isNull ( MStatus ReturnStatus = NULL  )  const

This method determines whether this plug is valid. A plug is valid if it refers to an attribute.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true this plug is not valid
  • false this plug is valid
Status Codes:
Examples:

MString MPlug::info ( MStatus ReturnStatus = NULL  )  const

This method returns a string containing the name of the node this plug belongs to and the attributes that the plug refers to. The string is of the form dependNode:atr1.atr2[].attr3 ...

This method is useful for debugging purposes.

Parameters:
[out] ReturnStatus Status Code
Returns:
Returns a string containing dependency node and attribute information for this plug.
Status Codes:
Examples:

bool MPlug::isFromReferencedFile ( MStatus ReturnStatus = NULL  )  const

This method determines whether this plug came from a referenced file. A plug is considered to have come from a referenced file if it is connected and that connection was made within a referenced file.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true plug was created within a referenced file
  • false plug was created within the current scene
Status Codes:
Examples:

bool MPlug::isDynamic ( MStatus ReturnStatus = NULL  )  const

Determines whether the attribute is of dynamic type or not.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true If the attribute is dynamic
  • false If this attribute is not added by user.
Status Codes:

bool MPlug::isIgnoredWhenRendering ( MStatus ReturnStatus = NULL  )  const

Determines whether a connection to the attribute should be ignored during rendering.

Parameters:
[out] ReturnStatus Status Code
Returns:
  • true If connected, the attribute should be ingored during rendering.
  • false If connected, the attribute should not be ingored during rendering.
Status Codes:

MPlug::FreeToChangeState MPlug::isFreeToChange ( bool  checkParents = true,
bool  checkChildren = true,
MStatus ReturnStatus = NULL 
) const

Returns true if the plug's value is allowed to be set directly. A plug isFreeToChange if it is not locked, and it is not a destination or if it is a destination, then it must be a special case (such as connected to an anim curve).

Normally this is not something that needs to be checked, since the DG or MEL operations take care of this for you.

If the parents are not free to change, then the children will not be free to change. However if the parents are free to change, some children may not be free to change.

Parameters:
[in] checkParents Check parent plugs.
[in] checkChildren Check child plugs.
[out] ReturnStatus Status Code
Returns:
  • kFreeToChange All tested plugs are free to change.
  • kNotFreeToChange Some of the tested plugs are not free to change.
  • kChildrenNotFreeToChange Some of the children are not free to change.
Status Codes:
Examples:

MDataHandle MPlug::constructHandle ( MDataBlock mBlock  )  const

This method returns a data handle constructed for this plug.

Returns:
MDataHandle for this plug

void MPlug::destructHandle ( MDataHandle mHandle  )  const

This method destructs the data handle for this plug.

MStatus MPlug::getValue ( MObject val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

This method returns a copy of the attribute value for the plug and not a reference. The setObject method of this class can be used to modify the plug's value.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asMObject method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:
  • MS::kSuccess Value exists and is non-null, and contains the correct information
  • MS::kFailure Either the value is a NULL value (kFailure) or the value does not exist (kObjectDoesNotExist failure)
Examples:

MStatus MPlug::getValue ( double &  val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asDouble method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( float &  val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asFloat method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( int &  val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asInt method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( short &  val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asShort method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( bool &  val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asBool method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( MDistance val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asMDistance method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( MAngle val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asMDGContext method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( MTime val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asMTime method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( char &  val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asChar method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::getValue ( MString val,
MDGContext ctx = MDGContext::fsNormal 
) const

NO SCRIPT SUPPORT.

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Python Notes

This method is not available from Python. See asString method instead.

Parameters:
[out] val Storage for the attribute value
[in] ctx Context in which to evaluate the plug (Default is normal)
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( MObject val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setMObject method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:
Examples:

MStatus MPlug::setValue ( MPxData val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setMPxData method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( MDataHandle handle  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references with the values in the handle. This method is most useful when the plug is an array plug, and you've filled the handle with data. Sending the value using this version of setValue will set the handle's data into the datablock and send out the appropriate attributeChanged messages to update the UI related to the attribute.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setMDataHandle method instead.

Parameters:
[in] handle The handle containing the data to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( double  val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setDouble method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( float  val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setFloat method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( int  val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setInt method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( short  val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setShort method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( bool  val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setBool method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( MDistance val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setMDistance method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( MAngle val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setMAngle method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( MTime val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setMTime method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( char  val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setChar method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( const MString val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setString method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setValue ( const char *  val  ) 

NO SCRIPT SUPPORT.

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Python Notes

This method is not available from Python. See setString method instead.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MObject MPlug::asMObject ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

This method returns a copy of the attribute value for the plug and not a reference. The setObject method of this class can be used to modify the plug's value.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as an MObject
Status Codes:
  • MS::kSuccess Value exists and is non-null, and contains the correct information
  • MS::kFailure Either the value is a NULL value (kFailure) or the value does not exist (kObjectDoesNotExist failure)

double MPlug::asDouble ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as a double
Status Codes:

float MPlug::asFloat ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as a float
Status Codes:

int MPlug::asInt ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as an int
Status Codes:

short MPlug::asShort ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as a short
Status Codes:

bool MPlug::asBool ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as a bool
Status Codes:

MDistance MPlug::asMDistance ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as an MDistance
Status Codes:

MAngle MPlug::asMAngle ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as an MAngle
Status Codes:

MTime MPlug::asMTime ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as an MTime
Status Codes:

char MPlug::asChar ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[in] ReturnStatus Status Code
Returns:
Value of plug as a char
Status Codes:

MString MPlug::asString ( MDGContext ctx = MDGContext::fsNormal,
MStatus ReturnStatus = NULL 
) const

Retrieve the current value of the attribute this plug references.

The default is to get the value at the current time. To specify an alternate time you must create a timed MDGContext that specifies the time of evaluation.

Parameters:
[in] ctx Context in which to evaluate the plug (Default is normal)
[out] ReturnStatus Status Code
Returns:
Value of plug as an MString
Status Codes:

MStatus MPlug::setMObject ( MObject val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setMPxData ( MPxData val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setMDataHandle ( MDataHandle handle  ) 

Set the current value of the attribute this plug references with the values in the handle. This method is most useful when the plug is an array plug, and you've filled the handle with data. Sending the value using this version of setValue will set the handle's data into the datablock and send out the appropriate attributeChanged messages to update the UI related to the attribute.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] handle The handle containing the data to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setDouble ( double  val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setFloat ( float  val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setInt ( int  val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setShort ( short  val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setBool ( bool  val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setMDistance ( MDistance val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setMAngle ( MAngle val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setMTime ( MTime val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setChar ( char  val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MStatus MPlug::setString ( const MString val  ) 

Set the current value of the attribute this plug references.

If the attribute is the destination of a connection then setting the value will have no effect as once the node is re-evaluated the attribute value will be reset.

Parameters:
[in] val The value to which the attribute will be set
Returns:
Status Code
Status Codes:

MPlug & MPlug::operator= ( const MPlug other  ) 

Assignment operator. Copies one plug to another.

Networked plugs are not allowed to be duplicated so if the RHS is a networked plug then a non-networked version is returned.

Parameters:
[in] other the plug to be copied
Returns:
A reference to the copied plug

MPlug MPlug::operator[] ( unsigned int  physicalIndex  )  const

This method will find and return a plug with the given physical index. This is the same as the elementByPhysicalIndex method.

Parameters:
[in] physicalIndex Array index of child plug
Returns:
A plug with the given index

bool MPlug::operator== ( const MPlug other  )  const

Comparison operator for MPlugs.

Plugs are considered equal if they refer to the same node and attribute unless both plugs are networked. In such cases a pointer comparison is done as there can only be one version of a networked plug.

If either or both plugs are null, the plugs are not considered equal.

Parameters:
[in] other Other plug to compare against
Returns:
  • true If the plugs are equal
  • false If the plugs are not equal

bool MPlug::operator== ( const MObject attr  )  const

Comparison operator for a plug and an attribute. This actually compares the plug's attribute against the other attribute.

Parameters:
[in] attr Attribute to compare against
Returns:
  • true If the plug's attribute is equal
  • false If the plug's attribute is not equal

bool MPlug::operator!= ( const MPlug other  )  const

The inequality operator for MPlugs.

Plugs are considered equal if they refer to the same node and attribute unless both plugs are networked. In such cases a pointer comparison is done as there can only be one version of a networked plug.

If either or both plugs are null, the plugs are not considered equal.

Parameters:
[in] other Other plug to compare against
Returns:
  • true If the plugs are not equal
  • false If the plugs are equal

bool MPlug::operator!= ( const MObject attr  )  const

The inequality operator for a plug and an attribute. This actually compares the plug's attribute against the other attribute.

Parameters:
[in] attr Attribute to compare against
Returns:
  • true If the plug's attribute is not equal
  • false If the plug's attribute is equal

MStatus MPlug::setNumElements ( unsigned int  elements  ) 

The method is used to pre-allocate the number of elements that an array plug will contain. The plug passed to this method must be an array plug and there must be no elements already allocated.

The numElements() method is used to find the number of elements already in the array plug.

Parameters:
[in] elements new array size
Returns:
  • kSuccess array plug size was changed
  • kFailure failed to change array plug size, plug is not array or array size is already non-zero.

MPlug MPlug::operator[] ( MObject attr  )  const

NO SCRIPT SUPPORT.

Returns a plug to the given attribute. This is only valid for attributes with no arrays in their ancestry.

Parameters:
[in] attr The attribute of the plug
Returns:
A plug referring to the given attribute, or a NULL plug if the operation fails.

MPlug::operator MObject (  )  const

NO SCRIPT SUPPORT.

This method returns the attribute for this plug.

Returns:
The attribute for this plug

bool MPlug::operator! (  )  const

NO SCRIPT SUPPORT.

Returns true if this plug is not valid. A plug is considered valid if it refers to an attribute.

Returns:
  • true The plug is NOT valid
  • false The plug is valid


Autodesk® Maya® 2009 © 1997-2008 Autodesk, Inc. All rights reserved. Generated with doxygen 1.5.6