//this script is made to work with autoColor. //it helps to eliminate overlapping by //assigning a sepparate shader to each shell on a polygonal object. //www.benbathen.com global proc autoShellAssign() { //Given a polygonal object find the number of UVs. string $object[] = `ls -sl`; autoProjection; select -r $object[0]; DeleteHistory; delete -ch; //Given a polygonal object find the number of UVs. string $object[] = `ls -sl`; //check to make sure only one polygonal object is being evaluated int $size = `size $object`; if ($size != 1) { error "Please use this script on one polygonal object at a time, Dude."; } //if only one is selected then: else { //find the number of UVs on the whole object. int $UVnum[] = `polyEvaluate -uv`; print "\n"; print "The feedback for autoShellAssign starts here."; print "\n"; print ("there are " + $UVnum[0] + " UVs on this object"); //convert the object selected to UVs select ($object[0] + ".map[0:" + $UVnum[0] + "]"); //put the UVs into a string array string $totalUVs[] = `ls -sl -fl`; print "\n"; //put the size of the string with all the UVs into a variable int $uvIntSize = `size $totalUVs`; //create a variable to use as an increment in the loop int $i; //loop through a series of commands to assign sepparate shaders to each shell while ($uvIntSize) { //select the first UV on the object select $totalUVs[0]; //convert the selection to a shell of UVs and put that selection into an array polySelectBorderShell 0; string $shell[] = `ls -sl -fl`; int $shellsize = `size $shell`; print "\n"; //remove this shells UVs from the total list of UVs $totalUVs = stringArrayRemove ($shell, $totalUVs ); //convert the selected UVs to faces. PolySelectConvert 1; //put the selected faces into a string string $selectedFace[] = `ls -sl`; print "\n"; print ("the first face on this shell is: " + $selectedFace[0]); print "\n"; //get the shader Group that the first face is in print "\n"; string $shaderGroupA[] = `listSets -type 1 -o $selectedFace[0]`; print ("the shader Group for this face is: " + $shaderGroupA[0]); print "\n"; //follow the connection to the shader group to find the shader print "\n"; string $shaderA[] = `listConnections -d off -s on ( $shaderGroupA[0] + ".surfaceShader")`; print ("the shader on this face is: " + $shaderA[0]); print "\n"; //duplicate the shader and the shader Group string $shaderGroupB[] = `duplicate $shaderGroupA[0]`; string $shaderB[] = `duplicate $shaderA[0]`; //connect the new shader to the new shader group connectAttr ($shaderB[0] + ".outColor") ($shaderGroupB[0] + ".surfaceShader"); //rename the shader group string $shaderGroupC2 = `rename $shaderGroupB[0] ($shaderB[0] + "SG")`; print $shaderGroupC2; //assign the new shader to the faces selected sets -e -forceElement $shaderGroupC2; //reevaluate the number of UVs in the UV variable $uvIntSize = `size $totalUVs`; print "\n"; print ("The size of the $totalUVs variable is " + $uvIntSize); } } }