How to create a “Toggle Wireframe on Shaded” shortcut in Maya 2019

Júlio Rodrigues ·

You got used to creating shortcuts for the most common actions of your workflow, but for some reason, Maya won’t let you easily create a shortcut for toggling “Wireframe on Shaded”. It’s doable but requires a script.

Knowing it’s possible is good, but now there’s a new task for you, finding a suitable script. They are not all the same, some only turn on (no turning off) the “Wireframe on Shaded” function, requiring you to create two shortcuts, one for turning them on and another one for turning them off, which is a waste of our precious “shortcut real estate”.

I suggest you assign the key 8 for it given that the other numbers are also responsible for changing how objects are seen.

The MEL Script. Commented

Script originally developed and made public by user Sanctuary @cgsociety. The functionality is tha same but I've changed the way it's implemented.

// gets current panel with focus
string $currPanel = `getPanel -withFocus`;

// gets the panel type
string $panelType = `getPanel -to $currPanel`;

// this is only applicable to the viewport (modelPanel in MEL's terminology)
if ($panelType == "modelPanel")
    // queries wireframeOnShaded state
    int $wireOn = `modelEditor -q -wireframeOnShaded $currPanel`;

    // toggles the mode
    $wireOn = !$wireOn;

    // finally sets the new mode
    modelEditor -e -wireframeOnShaded $wireOn $currPanel;
} else {
    error "The panel in focus is not a viewport.";

How to create a shortcut for this script (and any other script)

  1. Open the Hotkey Editor [Windows > Settings/Preference > Hotkey Editor]
  2. Select the Runtime Command Editor tab in the right pane
  3. Click New, paste in the script from the last section, give it a name and save.
  4. Back in the left panel, click Choose a category… choose Custom Scripts
  5. In the filtered list, select your previously created command and assign a hotkey combination for it (maybe the key 8?).

Classify in
  • Maya
  • Wireframe on Shaded
  • Shortcut
  • MEL
© Bladecast 2022. All rights reserved.