// =========================================================================== // 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. // =========================================================================== proc string[] uniqueTransformNodes( string $transNodes[] ) // // Description: // Eliminate all the double transform nodes, so the return list // has all the unique ones. // { string $uniqTrans[]; int $transIdx = 0; for ( $trans in $transNodes ) { int $skip = 0; for ($tmpTrans in $uniqTrans ) { if ( $trans == $tmpTrans ) { $skip = 1; break; } } // add it to the list if ( $skip == 0 ) { $uniqTrans[$transIdx] = $trans; $transIdx ++; } } return $uniqTrans; } global proc int art3dPaintCountShapes( string $shader ) // // Description: // Returns number of paintable shapes connected // to a given shader. We need to eliminate all // the intermediate objects from counting. // { int $numShapes = 0; string $shaderPlug = $shader + ".outColor"; string $shEngs[] = `listConnections $shaderPlug`; int $intermediate = 0; for( $sE in $shEngs ) { string $shEngPlug = $sE + ".dagSetMembers"; // bug id 150916, skip layered shaders if( `objExists $shEngPlug` == 0 ) continue; string $transNodes[] = `listConnections $shEngPlug`; string $trans[] = uniqueTransformNodes( $transNodes ); for ($t in $trans) { string $shapes[] = `listRelatives -shapes -pa $t`; for ( $s in $shapes ) { // Skip the intermediate objects. $intermediate = `getAttr ($s + ".intermediateObject")`; if ( $intermediate ) continue; $numShapes ++; } } } return $numShapes; }