// =========================================================================== // 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. // =========================================================================== // // Creation Date: 03 Apr 2000 // // Description: // Look at the shader connected to the input subdiv surface. // If if has no shader assigned then give it the default shader. // If it has a shader already, do nothing. // // Procedure Name: // subdAssignDefaultShader // // Input Arguments: // $subdiv: Subdiv shape to check for a shader. // If $subdiv is a transform, all subdiv shapes below it // will be processed. // // Return Value: // None. // global proc subdAssignDefaultShader( string $subdiv ) { // Sometimes the results of the above command can // be transforms above the subds... Check all the // leaf-level subds for shaders. // string $subdivShapes[] = `ls -dag -lf -type subdiv $subdiv`; for( $subdiv in $subdivShapes ) { // Check for connections to "instObjGroups" // If any of the connections are a shading engine, then we're done // int $foundShadingGroup = false ; string $connections[] = `listConnections ($subdiv + ".instObjGroups")`; if( size($connections) == 0 ) { // Check further for connections to "instObjGroups[].objectGroups" // int $attrSize = `getAttr -size ($subdiv + ".instObjGroups")`; int $i; for( $i = 0; $i < $attrSize ; $i ++ ) { $connections = `listConnections ($subdiv + ".instObjGroups[" + $i + "].objectGroups")`; for( $connection in $connections ) { if( `nodeType $connection` == "shadingEngine" ) { $foundShadingGroup = true; break; } } if( $foundShadingGroup ) break; } } else { for( $connection in $connections ) { if( `nodeType $connection` == "shadingEngine" ) { $foundShadingGroup = true; break; } } } if( !$foundShadingGroup ) { sets -edit -fe initialShadingGroup $subdiv; } } }