Go to: Synopsis. Return value. Related. Flags. MEL examples.


getAttr [-asString] [-caching] [-channelBox] [-expandEnvironmentVariables] [-keyable] [-lock] [-multiIndices] [-settable] [-silent] [-size] [-time time] [-type] attribute

getAttr is undoable, NOT queryable, and NOT editable.

This command returns the value of the named object's attribute. UI units are used where applicable. Currently, the types of attributes that can be displayed are:

Other data types cannot be retrieved. No result is returned if the attribute contains no data.

Return value

AnyValue or state of the attribute. The number and type of values returned is dependent on the attribute type.


addAttr, attributeQuery, connectAttr, disconnectAttr, listAttr, setAttr


asString, caching, channelBox, expandEnvironmentVariables, keyable, lock, multiIndices, settable, silent, size, time, type
Long name (short name) Argument types Properties
-keyable(-k) create
Returns the keyable state of the attribute.
-lock(-l) create
Returns the lock state of the attribute.
-type(-typ) create
Returns the type of data to expect at the attribute.
-size(-s) create
Returns the size of a multi-attribute array. Returns 1 if non-multi.
-time(-t) time create
Evaluate the attribute at the given time instead of the current time.
-silent(-sl) create
When evaluating an attribute that is not a numeric or string value, suppress the error message saying that the data cannot be displayed. The attribute will be evaluated even though its data cannot be displayed. This flag does not suppress all error messages, only those that are benign.
-settable(-se) create
Returns 1 if this attribute is currently settable by setAttr, 0 otherwise. An attribute is settable if it's not locked and either not connected, or has only keyframed animation.
-expandEnvironmentVariables(-x) create
Expand any environment variable and (tilde characters on UNIX) found in string attributes which are returned.
-asString(-as) create
This flag is only valid for enum attributes. It allows you to get the attribute values as strings instead of integer values. Note that the returned string value is dependent on the UI language Maya is running in (about -uiLanguage).
-channelBox(-cb) create
Returns whether the attribute is set to show in the channelBox. Keyable attributes also show in the channel box.
-caching(-ca) create
Returns whether the attribute is set to be cached internally
-multiIndices(-mi) create
If the attribute is a multi, this will return a list containing all of the valid indices for the attribute.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

createNode revolve -n gravityWell;
sphere -n loxTank;
cone -n noseCone;
cone -n fin;
pointConstraint -n weld fin noseCone;

float  $angle    = `getAttr gravityWell.esw`;
// Result: 360 //
string $type     = `getAttr -type loxTank.translate`;
// Result: double3 //
int    $lock     = `getAttr -lock noseCone.translateX`;
// Result: 0 //
float  $finZ     = `getAttr -time 12 fin.translateZ`;
// Result: 0 //
int    $size     = `getAttr -size weld.target`;
// Result: 1 //
int    $size     = `getAttr -settable weld.target`;
// Result: 0 //
float  $matrix[] = `getAttr loxTank.matrix`;
// Result: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 //
createNode file -n file1;
setAttr file1.ftn -type "string" "$TMPDIR/smile.gif";
string $s = `getAttr file1.ftn`;
// Result: $TMPDIR/smile.gif //
string $s = `getAttr -x file1.ftn`;
// Result: /var/tmp/smile.gif //

// Get the list of all used indices on a multi attribute
getAttr -multiIndices initialShadingGroup.dagSetMembers
// Result: 0 1 2 //