MPlug

Base Class

None.

Constants

NameTypeDescription
isFreeToChange Results
kFreeToChange int All tested plugs are free to change.
kNotFreeToChange int Some tested plugs are not free to change.
kChildrenNotFreeToChange int Some of the child plugs are not free to change.
Value Selectors
kAll int All values.
kNonDefault int Values not at their defaults.
kChanged int Values which have changed.
kLastAttrSelector int End of list. Used for counting.

Static Methods

None.

Static Attributes

None.

Constructors

SignatureParametersDescription
MPlug()   Default constructor. Returns a new, empty MPlug object.
MPlug(src) src - MPlug Copy constructor. Returns a new MPlug object referencing the same plug as src.
MPlug(node, attribute) node - MObject
attribute - MObject
Returns a new plug for the given attribute of the given node.

Object Methods

SignatureParametersReturnsDescription
array()   MPlug Returns a plug for the array of plugs of which this plug is an element. Raises a TypeError if this plug is not an element of an array of plugs.
asBool(context=MDGContext.kNormal) context - MDGContext bool Retrieves the plug's value, at the time specified by the context, as a boolean.
asChar(context=MDGContext.kNormal) context - MDGContext int Retrieves the plug's value, at the time specified by the context, as a single-byte integer.
asDouble(context=MDGContext.kNormal) context - MDGContext float Retrieves the plug's value, at the time specified by the context, as a double-precision float.
asFloat(context=MDGContext.kNormal) context - MDGContext float Retrieves the plug's value, at the time specified by the context, as a single-precision float.
asInt(context=MDGContext.kNormal) context - MDGContext int Retrieves the plug's value, at the time specified by the context, as a regular integer.
asMAngle(context=MDGContext.kNormal) context - MDGContext MAngle Retrieves the plug's value, at the time specified by the context, as an MAngle.
asMDistance(context=MDGContext.kNormal) context - MDGContext MDistance Retrieves the plug's value, at the time specified by the context, as an MDistance.
asMObject(context=MDGContext.kNormal) context - MDGContext MObject Retrieves the plug's value, at the time specified by the context, and returns it as an MObject containing a direct reference to the plug's data.
asMTime(context=MDGContext.kNormal) context - MDGContext MTime Retrieves the plug's value, at the time specified by the context, as an MTime.
asShort(context=MDGContext.kNormal) context - MDGContext int Retrieves the plug's value, at the time specified by the context, as a short integer.
asString(context=MDGContext.kNormal) context - MDGContext string Retrieves the plug's value, at the time specified by the context, as a string.
attribute()   MObject Returns the attribute currently referenced by this plug.
child(attribute) attribute - MObject MPlug Returns a plug for the specified child attribute of this plug. Raises a TypeError if this plug is not compound.
child(index) index - int MPlug Returns a plug for the index'th child of this plug. Raises a TypeError if this plug is not compound.
connectedTo(asDest, asSrc) asDest - bool
asSrc - bool
MPlugArray Returns an array of plugs which are connected to this one. If asDest is True connections in which this plug is the destination will be included in the array. If asSrc is True connections in which this plug is the source will be included in the array.
connectionByPhysicalIndex(index) index - int MPlug Returns a plug for the index'th connected element of this plug. Raises a TypeError if this plug is not an array of plugs.
constructHandle(block) block - MDataBlock MDataHandle Constructs a data handle for the plug.
destructHandle(handle) handle - MDataHandle Reference to self. Destroys a data handle previously constructed using constructHandle().
elementByLogicalIndex(index) index - int MPlug Returns a plug for the element of this plug array having the specified logical index. Raises a TypeError if this plug is not an array of plugs.
elementByPhysicalIndex(index) index - int MPlug Returns a plug for the element of this plug array having the specified physical index. Raises a TypeError if this plug is not an array of plugs.
evaluateNumElements()   int Like numElements() but evaluates all connected elements first to ensure that they are included in the count. Raises a TypeError if the plug is not a plug array.
getExistingArrayAttributeIndices()   MIntArray Returns an array of all the plug's logical indices which are currently in use. Raises a TypeError if the plug is not a plug array.
getSetAttrCmds(valueSelector=kAll, useLongNames=False) valueSelector - Value Selector constant
useLongNames - bool
list of strings Returns a list of strings containing the setAttr commands (in MEL syntax) for this plug and all of its descendents.
isFreeToChange(checkAncestors=True, checkChildren=True)   isFreeToChange Result constant Returns a value indicating if the plug's value can be changed, after taking into account the effects of locking and connections.
logicalIndex()   int Returns this plug's logical index within its parent array. Raises a TypeError if the plug is not an element of an array of plugs.
name()   string Returns the name of the plug.
node()   MObject Returns the node that this plug belongs to.
numChildren()   int Returns the number of children this plug has. Raises a TypeError if the plug is not compound.
numConnectedChildren()   int Returns the number of this plug's children which have connections. Raises a TypeError if the plug is not compound.
numConnectedElements()   int Returns the number of this plug's elements which have connections. Raises a TypeError if the plug is not an array of plugs.
numElements()   int Returns the number of the plug's logical indices which are currently in use. Connected elements which have not yet been evaluated may not yet fully exist and may be excluded from the count. Raises a TypeError if the plug is not a plug array.
parent()   MPlug Returns a plug for the parent of this plug. Raises a TypeError if this plug is not the child of a compound plug.
partialName(includeNodeName=False, includeNonMandatoryIndices=False, includeInstancedIndices=False, useAlias=False, useFullAttributePath=False, useLongNames=False) includeNodeName - bool
includeNonMandatorIndices - bool
includeInstancedIndices - bool
useAlias - bool
useFullAttributePath - bool
useLongNames - bool
string Returns the name of the plug, formatted according to various criteria.
selectAncestorLogicalIndex(index, attribute=MObject.kNullObj) index - int
attribute - MObject
Reference to self. Changes the logical index of the specified attribute in the plug's path. Raises a TypeError if the current plug is networked. or if attribute is not an array.
setAttribute(attr) attr - MObject Reference to self. Switches the plug to reference the given attribute of the same node as the previously referenced attribute.
setBool(value) value - bool Reference to self Sets the plug's value as a boolean.
setChar(value) value - int Reference to self Sets the plug's value as a single-byte integer.
setDouble(value) value - float Reference to self Sets the plug's value as a double-precision float.
setFloat(value) value - float Reference to self Sets the plug's value as a single-precision float.
setInt(value) value - int Reference to self Sets the plug's value as a regular integer.
setMAngle(value) value - MAngle Reference to self Sets the plug's value as an MAngle.
setMDataHandle(value) value - MDataHandle Reference to self Sets the plug's value using a data handle.
setMDistance(value) value - MDistance Reference to self Sets the plug's value as an MDistance.
setMObject(value) value - MObject Reference to self Sets the plug's value as an MObject.
setMPxData(value) value - MPxData Reference to self Sets the plug's value using custom plug-in data.
setMTime(value) value - MTime Reference to self Sets the plug's value as an MTime.
setNumElements(count) count - int Reference to self Pre-allocates space for count elements in an array of plugs. Raises a TypeError if the plug is not a plug array or if it already has elements.
setShort(value) value - int Reference to self Sets the plug's value as a short integer.
setString(value) value - string Reference to self Sets the plug's value as a string.

Object Attributes

NameTypeAccessDescription
info string R Description of the plug for debugging purposes, in the form node:attr1.attr2[].attr3...
isArray bool R True if plug is an array of plugs.
isCaching bool RW True if plug's value is being cached.
isChannelBox bool RW True if plug will appear in Maya's Channel Box.
isChild bool R True if plug is a child of a compound parent.
isCompound bool R True if plug is compound parent with children.
isConnected bool R True if plug has any connections.
isDestination bool R True if plug is the destination of a connection.
isDynamic bool R True if plug is dynamic.
isElement bool R True if plug is an element of an array of plugs.
isFromReferencedFile bool R True if plug is part of a connection from a referenced file.
isIgnoredWhenRendering bool R True if connections to plug are ignored during rendering.
isKeyable bool RW True if keys can be set on plug from Maya's UI.
isLocked bool RW True if plug is locked against changes.
isNetworked bool R True if plug is networked.
isNull bool R True if plug does not reference an attribute.
isProcedural bool R True if plug is procedural
isSource bool R True if plug is the source of a connection.

Sequence Support

None.

We explicitly do not support indexing because that is conditional on the plug being an array of plugs, which is not always the case, and due to potential confusion over logical versus physical index. Thus it is better handled through the elementByLogicalIndex() and elementByPhysicalIndex() methods.

Number Support

None.

Comparison Support

MPlug == MPlug True if both plugs refer to the same attribute of the same node.
MPlug == MObject True if the MObject refers to the same attribute as the plug.
MObject == MPlug True if the MObject refers to the same attribute as the plug.
MPlug != MPlug True if the plugs refer to different nodes, or to different attributes of the same node.
MPlug != MObject True if the MObject does not refer to the same attribute as the plug.
MObject != MPlug True if the MObject does not refer to the same attribute as the plug.

All other comparison operators will raise a TypeError exception.

© 2011 Autodesk, Inc. All rights reserved.