MEL How-To #67

Back · Previous · Next Maya

How do I control the visibility for the currently active Display Layer?

A quick scan through the MEL Command Reference indicates the following commands are available for accessing Display Layer information:

createDisplayLayer
editDisplayLayerGlobals
editDisplayLayerMembers

The second of these commands is used to query and set the current Display Layer; e.g.:

string $currentDisplayLayer = `editDisplayLayerGlobals -q -currentDisplayLayer`;
// Result: defaultLayer //

A Display Layer's visibility is controlled in the same manner as other Maya nodes -- that is, by its ‘.visibility’ attribute; e.g.:

setAttr defaultLayer.visibility true;

So, to toggle the visibility of the current Display Layer:

string $currentDisplayLayer = `editDisplayLayerGlobals -q -currentDisplayLayer`;

string $visAttr = ( $currentDisplayLayer + ".visibility" );

setAttr $visAttr ( !`getAttr $visAttr` );

Related How-To's

Monday, May 21, 2001