// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // Description: // This script is called from layerEditor.mel when the user // selects any of the menuItems from Set All Layers, Set // Selected Layers or Set Only Selected Layers. These items // change the value of the specified attribute. // // Arguments: // string $layers: layers to process "all", "selected" or "onlySelected" // string $attr: attribute to change eg. ".visibility" // int $value: attribute's new value global proc setLayerTo( string $layers, string $attr, int $value){ string $selectedLayers[]; string $allDisplayLayers[] = `layout -query -childArray LayerEditorDisplayLayerLayout`; string $layersToChange[]; if ($layers == "selected" || $layers == "onlySelected"){ // For each layer button check to see if it is selected. // int $index = 0; for ($thisLayer in $allDisplayLayers) { if (`layerButton -query -select $thisLayer`) { $selectedLayers[$index] = $thisLayer; if($attr == ".visibility") { setDisplayLayerVisibility($thisLayer, $value); } else if($attr == ".hideOnPlayback") { setDisplayLayerHideOnPlayback($thisLayer, $value); } else { eval("setAttr " + $thisLayer + $attr + " " + $value + ";"); } $index ++; } } $layersToChange = stringArrayRemove($selectedLayers, $allDisplayLayers); }else{ // Change every layer for ($thisLayer in $allDisplayLayers) { if($attr == ".visibility") { setDisplayLayerVisibility($thisLayer, $value); } else if($attr == ".hideOnPlayback") { setDisplayLayerHideOnPlayback($thisLayer, $value); } else { eval("setAttr " + $thisLayer + $attr + " " + $value + ";"); } } } if ($layers == "onlySelected"){ // Change status of unselected layers $value = !$value; for ( $thisLayer in $layersToChange ){ if($attr == ".visibility") { setDisplayLayerVisibility($thisLayer, $value); } else { eval("setAttr " + $thisLayer + $attr + " " + $value + ";"); } } } }