Attributes

 

An attribute is a characteristic or parameter of an object or other item in a scene. There are many ways to set attributes in Maya-with the Attribute Editor, MEL script, Toolbox tools, or expressions. You can set attributes to control virtually everything you can see in the work space.

The user can define new attributes. These attributes are handles the same way like the predefined ones.

For example, a NURBS sphere has attributes scaleX, scaleY, scaleZ, rotateX, and so on. You can set these attributes for the object with the Attribute Editor right after you create the object.

Object attribute names

An object attribute name has the following format:

objectName.attributeName

where objectName is the object's name and attributeName is the attribute's name of the object. A period divides the two parts of the name. Do not use spaces or special characters other than an underscore in an attribute name.

Example1

Create a sphere called Brawl with the following command:

    sphere -name Brawl;

You can get the value of one of its attributes with the getAttr command:

    float $yScale = `getAttr Brawl.scaleY`;

Brawl.scaleY is the full name of the scaleY attribute of the object Brawl.

 

Example2

You can set the value of one of its attributes with the setAttr command:

    setAttr Brawl.scaleY 15;

Brawl.scaleY is the full name of the scaleY attribute of the object Brawl.

 

Example3

To find out what the different attributes of an object are, you can either use different Editors like the Attribute Editor, Channelbox, etc. or the command listAttr:

    string $atts[] = `listAttr -k Brawl`;

The "-k" flag gives you the keyable attributes of an object, which are the most often used.

 

This website has been archived and is no longer maintained.