Click to go home...

MEL Scripts: Quick visibility swap

I'll frequently find myself toggling certain things on and off in Maya's views; i.e. swapping the visibility of NURBS curves on a character's rig. While it only takes a couple clicks to show or hide various components the standard way, it can still become tedious if it's being done a lot. As a result, I decided to script a little something that would simplify the process...

string $activePanel = `getPanel -wf`;
if (`modelEditor -q -joints $activePanel` == 1) {
 modelEditor -e -joints 0 $activePanel;
} else {
 modelEditor -e -joints 1 $activePanel;
}

Credits

The original handful of lines was written by me. It was simplified a bit by Keith Osborn, then simplified a hair further by me again.

Usage

The script toggles the visibility for a specific item in the active panel. In its current state, it toggles the visibility for joints. To change it so it works for a different component, change -joints to the appropriate item from the following list:

-nurbsCurves
-nurbsSurfaces
-polymeshes
-subdivSurfaces
-planes
-lights
-cameras
-joints
-ikHandles
-deformers
-dynamics
-locators
-dimensions
-pivots
-handles
-textures
-strokes

I've personally found that it's most useful as a shelf button (with an appropriate icon, of course), but some may prefer it as a hotkey. Use it however you wish.

Questions? Comments? Requests? Drop me a line!

back to script list