Datasheet

18
Chapter 1 Customization and MEL Scripting
With this code, the Windows command type prints out the contents of note.txt, which
is found in the same folder as the script. The contents are “captured” by the
popen command
and made available for
fgetline to read. $lineNumber establishes how many lines the text file
contains. Each line is temporarily stored by the
$line variable, allowing it to be printed with
the
print command.
As an additional working example, a MEL script named
video.mel is included in the
Chapter 1 mel folder on the CD. To use
video.mel, choose File Source Script in the Script
Editor. This script randomly retrieves phrases from two text files and creates humorous
video rental titles.
a
Industry Tip: Creating an “Expert Mode”
MEL Script
Some animators really enjoy creating custom MEL GUIs — so much so that they forgo the
standard Maya UI elements in favor of their own custom windows. One example comes from
Michael Stolworthy, an exhibit designer at GES. Michael has written
MDMwindow.mel, which is
designed to maximize the efficiency of a dual-monitor setup. The custom MEL window fills
one monitor, while the Maya interface, with hidden UI elements, fills the other.
The script is included in the Chapter 1 mel folder on the CD. To run the script, see the
MDMReadMe.txt file in the MDMwindow subfolder. The script works equally well on a single-
monitor setup.
MDMwindow.mel is not a short script. In fact, at 19 pages and 27,000+ characters, it can-
not be pasted into the Script Editor but can only be sourced. Nevertheless, like many MEL
scripts, many of its components are fairly basic and are simply repeated numerous times. In
terms of functionality,
MDMWindow.mel carries several unique features, a few of which are dis-
cussed with their matching piece of MEL code:
Imbedded panels The right half of the MEL window is dedicated to standard Maya panels. You
can set the panels to workspace views or windows such as the Hypergraph, Hypershade, and
Graph Editor; simply choose a Panels menu option.
The following MEL code is used to imbed the Outliner panel at the script’s start-up:
outlinerPanel; setParent..;
In order to arrange the panels, the paneLayout command is needed in the script:
paneLayout -configuration “right3”;
right3 signifies that there are three panes in the panel layout with two stacked on the right
side. The panes are divided by moveable separator lines. A total of 16 pane layouts are avail-
able. You can find descriptions of each in the “paneLayout” Maya help file.
07405c01.indd 1807405c01.indd 18 1/17/07 8:30:56 PM1/17/07 8:30:56 PM