/* toggleShadedOnSelected.mel created by Alex Hogan - www.alexhogan.com - in July, 2003 This script should toggle the shading override on any model surface. Problems - if the object is in a layer, that attribute is already controlled. */ proc string getShape( string $xform ) { string $shapes[]; $shapes[0] = $xform; // If given node is not a transform, assume it is a shape // and pass it through. if ( "transform" == `nodeType $xform` ) { $shapes = `listRelatives -fullPath -shapes $xform`; } return $shapes[0]; } proc string[] getSelectedMeshes() { string $selectedMeshes[]; int $numSelectedMeshes = 0; string $select[] = `ls -sl`; string $shape; for ( $node in $select ) { // Get the shape node $shape = getShape( $node ); // Assert that this shape node is indeed a mesh or surface if ( ( "mesh" == nodeType ( $shape ) ) || ( "subdiv" == nodeType ( $shape ) ) ) $selectedMeshes[ $numSelectedMeshes++ ] = $shape; } // Result is an array of all meshes included in // current selection list. return $selectedMeshes; } global proc toggleShadedOnSelected ( ) { print "\n"; //get list of selected surfaces string $selectedMeshes[]; $selectedMeshes = getSelectedMeshes(); //run through the list of selected meshes and toggle their shading on or off for ($mesh in $selectedMeshes) { // set override shading to on eval ( "setAttr " + $mesh + ".overrideEnabled 1" ); // store the current state, and toggle it string $isSet = eval ( "getAttr " + $mesh + ".overrideShading" ); if ( $isSet ) eval ( "setAttr " + $mesh + ".overrideShading 0 "); else eval ( "setAttr " + $mesh + ".overrideShading 1"); } }