Introduction to procedures
 
 
 

A procedure is a series of instructions that are separate from the main flow of the script. Procedures allow you to reuse certain portions of a script for new applications.

In this section, you use a procedure that is included with Maya (makeroll, which simulates an object rolling on a plane). Later in the lesson, you link this procedure to a user interface to provide an easier way to use the procedure.

To execute the makeRoll procedure

  1. Create a cube and a ground plane by typing the following in a MEL tab of the Script Editor:
    polyCube -name roll_Cube; polyPlane -height 10 -width 10;
    
  2. Execute the makeRoll procedure by typing the following in a MEL tab of the Script Editor:
    makeRoll roll_Cube 0 1 1.0;
    

    The makeRoll procedure requires the following arguments: the name of the object to act on, the height of the ground plane, the type of simulation, and the diameter of the object. The type of simulation is either box or sphere simulation. Rolling simulation is determined using a bounding sphere when simulation type is set to 0, or a bounding box when simulation type is set to 1.

  3. Set the current frame to two by selecting the current frame box and typing a two.

    The expressions set up by the makeRoll procedure only take effect when the frame is greater than one.

  4. Select the cube with the Move tool.
  5. Move the cube along the plane in X and Z using the Move tool.

    The cube rolls on the ground plane.

You have successfully loaded and used the makeRoll procedure. Now, you’ll link the procedure to a user interface.