Maya> other>Shelves Part 2

Shelves Part 2

Share |

Shelves Part 2

If you haven't read Shelves Part 1, click link. In this part, we'll be covering the creation of shelves and learn how to create icons for them.

Shelves; Updating Scripts

Where we left off, the script we'd created could delete history, freeze transformations, optimize the scene and save. The script looked like this.

select -allDagObjects;
FreezeTransformations;
OptimizeScene;
DeleteAllHistory;
file -save;


But, as Autodesk Area member hongodarongo pointed out, the delete history function of the script would delete all history, including skin data. This will not work if you have an animated scene. So we're changing the Delete History Function to this Delete History Function.

BakeAllNonDefHistory;

Now here's the script.

select -allDagObjects;
FreezeTransformations;
OptimizeScene;
BakeAllNonDefHistory;
file -save;


Now to update this change, or any other change you might want to do.

Step one - Go to window>settings/preferences>shelf editor. Go to the shelves tab.

click to enlarge

Step two - Select the shelf you added in the previous tutorial (save).

Step three - Go to the Shelf Contents tab and now you'll be able to see the selected shelf from the Shelf tab's contents. Select MaSave.

Step four - Go to Edit Commands. This will edit the commands that are run when the shelf icon is clicked. Now paste or type, in the textarea, the updated code. Click Save All Shelves and you're done.

Shelf Icons

Shelf icons are the pictures used to represent the functions that they run.

click to enlarge

Creating a Shelf Icon is quite simple. All you need is a program capable of creating a Bitmap. Then you save the Bitmap image in your icons folder in your documents.

Step one - In whatever Bitmap software you choose, create a new image that is 32px X 32px. Now draw your icon. If you don't want to bother doing that, just use this one.

Step two - Save the image in your icons folder in Your Documents. This is located at

C:\Documents and Settings\"your user name"\My Documents\Maya\"your version"\prefs\icons

Save it as a Bitmap, not a Jpeg or Tiff.

Now open up Maya, open the Shelf Editor and select the shelf content tab again and make sure the save shelf is selected. Select MaSave. Click on change image... The default image is at Mel script icon. Now locate the image where you saved it. Now the old shelf icon will be replaced by the new one.

Where Are Shelves Saved?

Shelves are saved at this location on your computer:

C:\Documents and Settings\"your user name"\My Documents\Maya\"your version"\prefs\shelves

First close Maya (go there using file explorer). Right click on the Mel script called shelf_save and open it using a text editor. This Mel script is what creates the shelf in Maya.

click to enlarge

Now notice that each shelf icon starts off with a ShelfButton function, then defines the attributes, then ends it with a ";". The options are pretty self-explanatory.

Changing A Shelf Through Code

Lets say you don't want that text over the icon with the name of the commands. What you do is edit this attribute:

-imageOverlayLabel

Remove the name from inside the "" and leave it blank. Save it and re-open Maya. Now the text over the icon will be removed. Move your mouse over the icon. A yellow tag will pop up with the code that we used to create these commands. It would be much more helpful if this was explaining the function of this button like it does if you were to move your mouse over history. To fix this, close Maya and go back to the shelf script. This time we're going to be editing this attribute:

-annotation

Now, remove the code inside the "" and replace it with "this will select all objects, freeze transformations, optimize the scene, and save the scene". Now it will look like this.

-annotation "this will select all objects, freeze transformations, optimize the scene, and save the scene"

Save it and re-open Maya. Now when you move the mouse over it, the pop-up reads that sentence.

You can learn more about the shelves attributes by going to help>Mel command reference, in the by substring(s) categorizations, enter shelfButton, hit enter, and select shelfButton. This will list all of the options.

click to enlarge

Conclusion

I hope in this tutorial series you have been able to gain a basic knowledge of shelves.

turbosquid
Visit The3dStudio.com
Home Tutorials About the Author Site Map
User Agreement Privacy Policy ©2015