Create a Custom Drop-down menu in Maya
In the last lesson we added a new shelf and some custom buttons. In this lesson we will add an entire drop down menu. Just like your File, Edit, View menu in Maya, you can have your own drop-down menu. This will get you started by creating a simple drop-down list of your favorite mel scripts.
First off we need some mel scripts. Hopefully you've got a couple of favorites already or else you are reading this for some odd reason known only to you. Either way, you need some mel scripts. For this tutorial we will assume you have three favorite mel scripts. They should be named "alpha.mel", "bravo.mel", and "charlie.mel". Place all three mel scripts in your maya/scripts/ folder. Here's an example alpha.mel you can use if you don't feel like scrounging up mel scripts for this purpose.
//My Maya Alpha MEL script
polyCube;
scale 3 2 1;
Make sure each mel script is different enough so you can tell it's working when we run this. With the three files in place, we need one more mel file called myMenu.mel. Here's the code for "myMenu.mel"
You can see the three lines we needed above are pretty simple. You can add or subtract as many lines as you need for your own menu. Notice also i used the source option for the command of the menu button, this is optional but i needed it. Now you can store several mel scripts in one easy place. You will need to run this script however to make them show up in the menu. Running the script can be attached to one of our custom buttons on our Beta shelf if we wanted it to be. Just drag the text 'source "myMenu.mel"' to your custom Beta shelf.
If you want the menu to always appear without the need of a button you have a couple of options. I will show you the one that works for me in Maya 6.0. I opened the file
"my docs/maya/scripts/userSetup.mel" and at the very bottom i place the line:
{myMenu;}
OK, the file wasn't there, so i created one called userSetup.mel and placed the line above in the file. That did the trick and i can edit my userSetup.mel further for more customizations later.
Now whenever i start Maya, my custom Main Window drop down is automatically displayed automatically. I should point out that editing the file initialLayout.mel is considered dangerous territory. Tread lightly with plenty of back-ups and the ability to reinstall should something really bad happen. I have misedtied this file before and crashed Maya, restoring the file fixed the problem. Treead lightly but enjoy the heck out of your new Maya custom menu.
|