Datasheet

4
Chapter 1 Customization and MEL Scripting
If need be, you can edit any of the files in the prefs folder with a text editor. Perhaps the
most useful file to edit by hand is
userRunTimeCommands.mel, in which it’s easy to delete cus-
tom commands that are no longer needed.
You can force Maya to update the files in the
prefs folder by executing the savePrefs com-
mand in the Script Editor. The
savePrefs command offers various flags, such as -uiLayout,
that allow you to update specific files.
In addition, on each exit, Maya forces all tools that are not on a shelf to save their custom
settings as optionVars. optionVars are specialized variables that survive multiple invocations
of Maya. That is, if you exit Maya and open it later, the optionVars, with their correct values,
remain accessible and readable (optionVars are written out to the disk). Aside from the option-
Vars created by the Preferences window, however, optionVars are not accessible outside Maya.
Nevertheless, you can create your own custom optionVars at any time and then retrieve the
values with the
-query or -q flag, as in this example:
optionVar -intValue “WorkOrderNumber” 57235;
optionVar -query “WorkOrderNumber”;
Last, you can force Maya to save tool settings and update corresponding optionVars by
executing the
saveToolSettings command in the Script Editor.
a
Creating Custom Shelf Icons
Many Maya books have touched on the customization of shelves inside Maya. Nevertheless,
they are so amazingly flexible that they are worth an additional look.
Maya comes from the factory with a set of ready-made shelves full of shelf icons (also
referred to as shelf buttons). You can delete any of these by choosing Window
Settings/
Preferences
Shelf Editor, selecting the Shelves tab, highlighting the shelf that is undesired,
and clicking the Delete Shelf button. To make a new, empty shelf, click the New Shelf button.
There are several ways to populate a shelf with shelf icons. Pressing Ctrl+Alt+Shift and
selecting a menu item, such as a tool, adds an icon to whichever shelf is visible at the time.
Pressing Ctrl+Alt+Shift and selecting the options box of a tool also adds a shelf icon; in this
case, clicking the icon opens the tool options window instead of applying the tool immedi-
ately with its prior settings.
You can also highlight and MMB drag any script lines you find in the Script Editor and
drop them onto a shelf. A generic “mel” icon is created. When the icon is clicked, Maya runs
through all the lines that were MMB dragged regardless of what they were. The shelf icon
may be as simple as a single MEL line, such as
performPlayblast true, which opens the Play-
blast options window. The icon may be as complex as the 200 lines necessary to create an
entire skeleton. Once a shelf icon exists, you can edit the contained script lines in the Shelf
07405c01.indd 407405c01.indd 4 1/17/07 8:30:47 PM1/17/07 8:30:47 PM