Wednesday, May 8, 2013

Source a MEL script with a shelf icon in Maya


Well it happened  you found a MEL or Python script you just love using over and over, now you just need to create a quick shelf icon so you can start it instantly.


First your script needs to be installed and working properly. If you need to find your scripts path down in the MEL box at the bottom of maya you can type "internalVar -usd;" no quotes. It should tell you:

// Result: C:/Users/Computername/Documents/maya/2013-x64/scripts/

Once you have your script installed and working, Source it once to get it into memory in Maya, by typing "source YourScriptName;" no quotes. In the Mel box at the bottom.  YourScriptName obviously being the name of your script.



Then go to the little down pointing arrow at the far left near the shelves and click it, a menu pops up select "Shelf Editor"




The shelf Editor Appears. First select the shelf you like to add your icon to in the "shelves" list on the LEFT. Then press the New icon button on the RIGHT. This creates a new entry titled "User Script" at the bottom and a new Icon with a little Maya symbol appears in your Shelf up at the top of Maya.



You can give it a name of your choosing in the Rename field. Choose an icon of your own creation or pick from the Maya icons. The other settings there are pretty intuitive. You can create a tool tip for your icon and the Icon label will add text on top of your icon if you wish. Once done it's time to connect our code to the icon.





Select the Command Tab in the Shelf Editor. By default it will read:
print("User defined macro");



Between the quotes is what will read down in the script line at the bottom of the screen when you click on your icon. You can change it to "Ran Brick Tool" Or whatever you wish to display when run. If you don't want it just delete the whole line if you want it place your own code line above it.
"Source YourScriptName;" (no quotes)





Then go back to the Shelves tab in the Shelf Editor and press the "Save All Shelves" button at the bottom. 

That's it. Now you should have a nice icon to execute your script with! Let me know if you have any issues following the tutorial.
Please check "HELPFUL" below if it was, if not COMMENT below and tell me why! Don't miss another tutorial or tip! Subscribe to Maya Zest