Modifying object attributes

 
 
 

When you perform an action on an object in the Maya user interface, you are using Maya commands to change the attributes of selected objects. You can use the same Maya commands explicitly to edit the attributes of objects in the scene.

To use the move command

  1. With the polygonal cube selected, type the following in the Script Editor:
    move 3 2 1;
    

    The polygonal cube is moved to the XYZ co-ordinates 3,2,1.

    The move command has set the translate attributes to the specified arguments of the command. These arguments are called command arguments as they are not used with flags.

    When a command is typed into the Script Editor, it acts on the current selection, unless an object name is provided as an argument to the command.

  2. With the polygonal cube selected, type the following in the Script Editor:
    move -1 -2 -3 -relative;
    

    The polygonal cube moved relative to its current position by -1,-2,-3 in XYZ.

    The move command is used with the relative flag to change the method in which the command executes. The relative flag does not have any arguments; the values -1,-2,-3 are command arguments used with the move command. The values are prefaced by a negative sign, but are not recognized as flags as they do not contain any of the flag keywords.

This is equivalent to using the Move tool in the Maya interface.

To specify attributes of geometry with flags

  1. Create a polygonal sphere with a radius of two and four subdivisions in X by typing the following in the Script Editor:
    polySphere -radius 2 -subdivisionsX 4;
    

    The radius flag allows you to specify a value for the radius of the sphere. The value 2 is associated with the radius flag, and is not a command argument.

This is equivalent to specifying values within the Polygon Sphere Options dialog in the Maya interface.

NoteFlags have short and long names. Commands execute the same way whether or not you use long or short flag names. The above command could have been typed as:

polySphere -r 2 -sX 4;

Some flags have the same short names, but they are used in different contexts so it does not affect the execution of the script. For example: -r is the short name of the -relative flag, used with the move command, -r is also the short name of the -radius flag, used with the sphere command.

  1. The sphere has a default name of pSphere#. Rename the selected sphere by typing the following in the Script Editor:
    rename test_Sphere;
    

    The rename command changes the name of the currently selected object. If multiple objects are selected, the rename command renames the selected objects to the specified name with a numerical index appended, as every object must have a unique name.

This is equivalent to renaming an object with the Attribute Editor or the Channel Box in the Maya interface.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License