Skip to content

Create Shelf Buttons / Hotkeys 🛠

All tools are acompanied with instructions on how to setup and activate using the accompanied code in Maya.

To get the most out of these and boost your productivity, you will need to either create a shelf button or a hotkey in the hotkey editor in Maya.

Creating a Shelf Button

For this example we will use the Bevel mel code provided in the Free Tools section.

Info - Mel / Python source

The programming language will always be either Mel or Python. Please refer to each tool's page to tell you which which programming language to use during the installation process (refer to the installation page of each tool for detailed instructions).

1
2
3
    dR_DoCmd("bevelPress");
    string $getBevelNode[] = `listHistory -lv 1`;
    setAttr ($getBevelNode[1] + ".subdivideNgons") 1;

Copy these 3 lines of code and open Maya.

In Maya there's different ways to create a shelf button.

From the main viewport

Creating a shelf button using the Mel (or) Python execution of the command line source.

Shelf Button 1

Info - Mel / Python source

You can switch between Mel and Python languages by clicking on the name.

Each tool's page will tell you which which programming language to use during the installation process (please refer to the installation page of each specific tool for detailed instructions).

Switching bewteen Maya/Python is not that necessary at this moment as Maya will prompt us to choose the language we want to use later.

Set the command line source is set to Mel (as that is the programming language used for this specific tool) and paste in the code.

Shelf Button 2

From here select/highlight the code (Ctrl + a) then Middle Mouse drag the text on your shelf.

Once dragged a pop up window will appear 'Save script to shelf as type:' since our code is in mel select Mel.

Shelf Button 3 Shelf Drag gif 1

Your Shelf button is now created and you can now activate the tool by clicking on the button. Shelf Button 4 Shelf_Bevel_Press_1

Info - Command Line

If you are missing the command line at the bottom of Maya's interface, go to Windows ➡ UI Elements ➡ and make sure Command Line checkbox is checked.

Shelf Button 5

From the script editor

The process of creating a shelf buton from the script editor is quite the same as above.

  1. Open the script editor.
    1. Go to Windows ➡ General Editors ➡ Script Editor to open the script editor. Script Editor 1
    2. or open it from the bottom right corner of your Maya window. Script Editor 2

The script editor window should pop up. Script Editor 3

  • Right Click on the bottom half section of the script editor and create a new Mel tab.
Info - Python/Mel tabs

Each tool's page will tell you which which programming language to use during the installation process (please refer to the installation page of each specific tool for detailed instructions).

Script Editor 4

Script Editor 5

  • Copy paste in the Mel script.
  • Highlight/Select the text (Ctrl + a).
  • Middle Mouse drag the text on your shelf.

Script Editor 6

Maya knows its a mel script and will create the shelf button for us.

Script_Editor_Gif_1 Shelf Bevel Press1

Important - Close Maya to save Shelf Button

It's best to close and re-open Maya after making buttons or hotkeys because if Maya crashes, you will have to repeat the process all over again.

Adding a custom icon for your Shelf Button

Occasionally tools will be shipped with an icon. You can use that icon to add it on your shelf button.

Let see how to set that up.

Coming soon!

Create a Hotkey

For this example we will be using the Mirror Tool python code as an example.

1
2
from mirror_Tool import OpenImportDialog
OpenImportDialog.show_dialog()

To set a Hotkey first open the Hotkey Editor Window located in:

Windows-> Settings/Preferences-> Hotkey Editor.

Hotkey Editor 1

Once opened, choose Custom Scripts from the Edit Hotkeys dropdown and click on Runtime Command Editor.

Hotkey Editor 2

From there click on New:

Name: Mirror_Tool
Description: Mirror_Tool (use same as Name, you could alternatively use a small description if you like)
Language: Python (always check on the How to Install page of each tool, to see which language to use)

Then copy paste the python code underneath the language area.

Hotkey Editor 3

Once happy click on Save Runtime Command

Your new hotkey should now be added in the custom scripts drowpdown. From there click on the Hotkey area and assign your hotkey.

Hotkey Editor 4

Important - Close Maya to save HotKey

It's best to close and re-open Maya after saving your hotkeys because if Maya crashes, you will have to repeat the process all over again.