|
This tutorial will cover how to make shelves and create Mel scripts to speed up repetitive tasks.
Creating A New Shelf
We're going to create a new shelf and call it save. This shelf will
contain buttons on it that will help you save a scene in Maya.
Step one -Go to window>settings/preferences>shelf editor. Click on the tab shelves. 
Step two - Click the new shelf button.
Step three- Set it's name to save.
Close the shelf editor.
Making It Do Something
A lot of times before you save you'll want to delete
your history, freeze your transformations, so now we'll start filing it
up. Our shelf will have three icons. Freeze transformations, optimize
scene, and a mel script I'll show you how to make later.
Step one - We're going to ad freeze transformations to the
shelf. Hold the ctrl and shift keys and then go to modify>freeze
transformations. You'll see it added to the shelf.
Step two - repeat this task with optimize scene. Go to file>optimize scene size.
Step three - Now add delete history to the shelf. Go to edit>delete all by type>history.
Mel
here we're going to learn how to create a little mel script of all our commands.
Open the script editor by the screen icon. 
In the script editor window, go to edit>clear history. You'll see
that the top half of the script editor will go blank, erasing all the
history of all the commands we did.
Hit freeze transformations on your shelf. Now Maya should tell
you that you didn't have anything selected. That's alright. I'll show
you what we'll do later. Now hit optimize scene. Averify action window
will come up. Hit cancel. We don't actually need to do it right now.
Now click delete history from your shelf. In thescript editor you'll
see it recorded everything you did. What we need to get is only the
important parts of this list of commands we did. They're in bold text.
FreezeTransformations;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 2 -jointOrient;
// Error: This command requires at least 1 argument(s) to be specified or selected; found 0. //
OptimizeScene;
DeleteAllHistory;
Now copy the important parts into the bottom half of the script editor as they appear. 
Now for this code to work, we're going to need to be able to tell Maya
to select all the objects in the scene. To do this, we're going to use
this piece of code select -allDagObjects;. Put this at the top of your
script. Now the script should look like this;
select -allDagObjects;
FreezeTransformations;
OptimizeScene;
DeleteAllHistory;
Now the last thing we want our script to do is save the scene.
Add this piece of code file -save; to the end of the script. Now it
should look like this;
select -allDagObjects;
FreezeTransformations;
OptimizeScene;
DeleteAllHistory;
file -save;
Now select the code in the script editor and on the script editors
menu go to file>save script to shelf... Name the script MaSave. It
will create a new shelf icon on the save shelf. Click the icon and it
will run these commands. As you can see this would save you lots of
time for saving a scene.
|