string $selectedObjs[] = `ls -sl`; //get selected objects for ($obj in $selectedObjs){ //iterate on selected objects string $newMat = `shadingNode -asShader "lambert"`; //create a lambert string $rnMat = `rename $newMat ($obj + "_Lmb_Mat")`; //rename new material based on object [optional] string $newSG = `sets -renderable true -noSurfaceShader true -empty -name ($rnMat + "SG")`; //create a shading group connectAttr -f ($rnMat + ".outColor") ($newSG + ".surfaceShader"); //connect shading group to lambert sets -e -forceElement $newSG $obj; //connect material to object }
such a lifesaver little script.. should be there in hypershade menu by default!A little script should be just the thing:
Code:string $selectedObjs[] = `ls -sl`; //get selected objects for ($obj in $selectedObjs){ //iterate on selected objects string $newMat = `shadingNode -asShader "lambert"`; //create a lambert string $rnMat = `rename $newMat ($obj + "_Lmb_Mat")`; //rename new material based on object [optional] string $newSG = `sets -renderable true -noSurfaceShader true -empty -name ($rnMat + "SG")`; //create a shading group connectAttr -f ($rnMat + ".outColor") ($newSG + ".surfaceShader"); //connect shading group to lambert sets -e -forceElement $newSG $obj; //connect material to object }