Observing script history
 
 
 

The Script Editor displays a running history of executed commands and the results of commands that Maya executes. You can copy most commands from the history section of the Script Editor and paste them in the input section to execute them.

To set up the Script Editor

  1. Select Window > General Editors > Script Editor.

    The Script Editor window opens.

The lower half of the Script Editor is the input section where you enter scripting commands.

By default, Maya displays basic feedback from executed commands. However, when Echo All Commands is on, Maya shows all the history from a command, including when a script calls another script or modifies elements of the user interface. While learning MEL, the extra lines of output produced when Echo All Commands is on can be confusing because there is so much output. As you become more experienced in MEL, the extra lines of history can be useful for debugging a MEL script.

  1. In the Script Editor window, ensure that there is not a check mark beside History > Echo All Commands.

To observe script history

  1. In the Script Editor, click the Clear History button.

    You can more easily isolate the command history created by the commands you perform when there is no other history in the Script Editor.

  2. From the Shelf, select the Surfaces tab in order to view the tools located on that shelf.
  3. Click the NURBS Sphere button on the Surfaces Shelf.

    Command history is displayed in the history section of the Script Editor:

    CreateNURBSSphere;
    sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1;objectMoveCommand;
    

    Several MEL commands are executed when the Shelf button is pressed. The following happens when the button is pressed:

    • The NURBS Sphere button on the surfaces Shelf executes a script called CreateNURBSSphere;.
    • The CreateNURBSSphere script calls the sphere MEL command using flags to set the arguments of the command to the values currently specified in the NURBS Sphere menu option window. The sphere MEL command is using flags in short form.
    • The objectMoveCommand is executed every time a primitive is created. It moves the created object to the origin.

    Commands in MEL must be separated with semicolons. Additional spaces and additional carriage returns do not affect the execution of the scripts. Blank spaces and returns make scripts easier to read. Flags cannot be separated from the hyphen character by extra spaces or returns.

TipFor more details on these flags, see sphere in the MEL Command Reference.

The MEL Command Reference gives a complete listing of the functionality of all MEL commands and flags.

Note

You can copy commands from the Script Editor history section and paste them in the input section to execute them.

  1. Delete the NURBS sphere by pressing the delete key on your keyboard.

To type a MEL command in the Script Editor

  1. Select a MEL tab in the Script Editor.

    Script Editor tabs allow you to quickly switch between MEL and Python script entry modes. You can create additional Script Editor tabs to serve as a temporary holding area for scripts.

  2. Type the following command in the input section of the Script Editor.
    polyCube;
    
    Tip

    When asked to type a command, you can copy it from these tutorials and paste it into the Script Editor input section.

  3. Execute the command by pressing on the numeric part of your keyboard.

    You must always type on the numeric keypad or + (the regular Enter on your keyboard) to execute commands. Typing regular just creates a new line in the Script Editor input.

    A polygonal cube is created at the origin.

    The command is removed from the input section of the Script Editor after execution. The command and the result of the command is output to the history section of the Script Editor:

    polyCube;// Result: pCube1 polyCube1 //

    Note

    In future lessons, when a series of MEL or Python commands creates output, only the output created by the commands will be referred to as output to the Script Editor.

Comments in MEL begin with // and anything which follows these characters on a line is ignored by MEL. The same convention is used for displaying results of commands and output in the Script Editor history section. Similarly, results, comments and messages output by Python are prefaced with the Python commenting character ( # ).

Note

In the rest of this lesson and the remaining MEL lessons, when asked to type a command, execute the command after typing it with the Enter on the numeric keypad on your keyboard. You can also execute commands with + (Windows) or + (Mac OS X).

Tip

If you do not want the command to be removed from the input section of the Script Editor after execution, highlight the command before execution by selecting it with the mouse.