Datasheet

7
On the first line of the script, the window command describes the GUI window. On the
last line,
showWindow newWindow launches the described window. A variation of the window
command is mandatory if a pop-up window is desired.
If you write a new MEL script, or adapt an example, and the script fails to run, a red
error message appears on the Command line.
(Top) A red MEL error on the Command line. (Bottom) A MEL error message in the Script Editor. In
this example, a quotation mark is missing before the ending semicolon.
If Maya has an issue with a specific part of the script, it will add a brief explanation to
the Script Editor. Usually, broken MEL scripts are a result of a mistyping, a misspelling, or
a missing semicolon, which needs to appear at the end of each command (except for those
with an opening { or closing } curly bracket).
a
Building an Intermediate MEL Window
MEL scripting provides numerous ways to organize the look of a window and to control the
way in which it operates. As an example, an intermediate MEL script named
newcam.mel is
included in the Chapter 1 mel folder on the CD.
newcam.mel allows the user to create a 1-, 2-,
or 3-node camera with the click of a button.
To use
newcam.mel, open the Script Editor, choose File Source Script, and browse for the
file.
newcam.mel is loaded into memory but will not run instantly. You must type newca m in
the Script Editor work area and press Ctrl+Enter for the window
to appear. To create a new camera, type a new value into the Focal
Length field, press Enter, type a new value into the Far Clipping
Plane field, press Enter, and click either the 1 Node, 2 Node, or 3
Node button. Ctrl+Entering
newcam in the work area is required by
the
proc command. The script starts like this:
global proc newcam () {
proc stands for procedure. A procedure is a group of MEL statements that can be used
multiple times in a script. The start of a procedure is defined by an opening curly bracket {,
which appears after the procedure name and double parentheses. The end of a procedure is
newcam.mel allows users
to create camera with
the click of a button.
Building an Intermediate MEL Window
07405c01.indd 707405c01.indd 7 1/17/07 8:30:49 PM1/17/07 8:30:49 PM