Here's a script I wrote a little while ago to help deal with the millions of lamberts that Craft Director makes (well maybe not millions... but I have seen them go into the multiple hundreds on complex scenes). This should grab most cdt lamberts, if I missed any let me know.
Code: Select all
//###################################] C2i Studios [#######################################
// Script Name: cdtCleanMats.mel
//
// By: Yuris Mangolds - ymangolds@c-2iinc.com
//
// Version: 0.2
//
// Last Updated: 12/10/08
//
// Bugs/Comments/Suggestions: Send to ymangolds@c-2iinc.com
//
// Update/Change this file at:
// http://c-2iinc.dyndns.org:8001/Public/cdtCleanMaterials.mel
//
// Compatibility: Writen for Maya 2008
//
// Description: A tool to help clean and organize the materials created when using Craft
// Director Tools.
//
// Installation: Place this script in your user scripts directory then run "cdtCleanMats"
//
// Notes: At the end of the script it removes unused render nodes (previous cdt lamberts)
// So make sure any materials you've created otherwise are assigned to something.
//
//#########################################################################################
global proc cdtCleanMats(){
int $makeBeigeLgt = 1;
int $makeBeigeMed = 1;
int $makeBeigeDark = 1;
int $makeBlue = 1;
int $makeGreenLgt = 1;
int $makeGreenMed = 1;
int $makeGreenDark = 1;
int $makeGrey = 1;
int $makeOrange = 1;
int $makePurpLgt = 1;
int $makePurpDark = 1;
int $makeRedLgt = 1;
int $makeRedMed = 1;
int $makeTealLgt = 1;
int $makeTealMed = 1;
int $makeWhite = 1;
int $makeYellow = 1;
string $materials[] = `ls -mat`;
string $lamberts[] = `ls -type "lambert"`;
//check for materials
for ($mat in $materials){
if ($mat == "cdtBeigeLgt") $makeBeigeLgt = 0;
else if ($mat == "cdtBeigeMed") $makeBeigeMed = 0;
else if ($mat == "cdtBeigeDark") $makeBeigeDark = 0;
else if ($mat == "cdtBlue") $makeBlue = 0;
else if ($mat == "cdtGreenLgt") $makeGreenLgt = 0;
else if ($mat == "cdtGreenMed") $makeGreenMed = 0;
else if ($mat == "cdtGreenDark") $makeGreenDark = 0;
else if ($mat == "cdtGrey") $makeGrey = 0;
else if ($mat == "cdtOrange") $makeOrange = 0;
else if ($mat == "cdtPurpLgt") $makePurpLgt = 0;
else if ($mat == "cdtPurpDark") $makePurpDark = 0;
else if ($mat == "cdtRedLgt") $makeRedLgt = 0;
else if ($mat == "cdtRedMed") $makeRedMed = 0;
else if ($mat == "cdtTealLgt") $makeTealLgt = 0;
else if ($mat == "cdtTealMed") $makeTealMed = 0;
else if ($mat == "cdtWhite") $makeWhite = 0;
else if ($mat == "cdtYellow") $makeYellow = 0;
}
//Make new materials
if ($makeBeigeLgt == 1){
string $cdtBeigeLgt = `shadingNode -asShader lambert -n "cdtBeigeLgt"`;
string $cdtBeigeLgtSG = `sets -renderable true -noSurfaceShader true -empty -n cdtBeigeLgtSG`;
connectAttr -f ($cdtBeigeLgt + ".outColor") ($cdtBeigeLgtSG + ".surfaceShader");
setAttr ($cdtBeigeLgt + ".color") 0.941176 0.988235 0.705882;
} else { string $cdtBeigeLgtSG = "cdtBeigeLgtSG";}
if ($makeBeigeMed == 1){
string $cdtBeigeMed = `shadingNode -asShader lambert -n "cdtBeigeMed"`;
string $cdtBeigeMedSG = `sets -renderable true -noSurfaceShader true -empty -n cdtBeigeMedSG`;
connectAttr -f ($cdtBeigeMed + ".outColor") ($cdtBeigeMedSG + ".surfaceShader");
setAttr ($cdtBeigeMed + ".color") 0.784314 0.823529 0.588235;
} else { string $cdtBeigeMedSG = "cdtBeigeMedSG";}
if ($makeBeigeDark == 1){
string $cdtBeigeDark = `shadingNode -asShader lambert -n "cdtBeigeDark"`;
string $cdtBeigeDarkSG = `sets -renderable true -noSurfaceShader true -empty -n cdtBeigeDarkSG`;
connectAttr -f ($cdtBeigeDark + ".outColor") ($cdtBeigeDarkSG + ".surfaceShader");
setAttr ($cdtBeigeDark + ".color") 0.54902 0.576471 0.411765;
} else { string $cdtBeigeDarkSG = "cdtBeigeDarkSG";}
if ($makeBlue == 1){
string $cdtBlue = `shadingNode -asShader lambert -n "cdtBlue"`;
string $cdtBlueSG = `sets -renderable true -noSurfaceShader true -empty -n cdtBlueSG`;
connectAttr -f ($cdtBlue + ".outColor") ($cdtBlueSG + ".surfaceShader");
setAttr ($cdtBlue + ".color") 0.227 0.522 0.824;
} else { string $cdtBlueSG = "cdtBlueSG";}
if ($makeGreenLgt == 1){
string $cdtGreenLgt = `shadingNode -asShader lambert -n "cdtGreenLgt"`;
string $cdtGreenLgtSG = `sets -renderable true -noSurfaceShader true -empty -n cdtGreenLgtSG`;
connectAttr -f ($cdtGreenLgt + ".outColor") ($cdtGreenLgtSG + ".surfaceShader");
setAttr ($cdtGreenLgt + ".color") 0.337255 0.878431 0.337255;
} else { string $cdtGreenLgtSG = "cdtGreenLgtSG";}
if ($makeGreenMed == 1){
string $cdtGreenMed = `shadingNode -asShader lambert -n "cdtGreenMed"`;
string $cdtGreenMedSG = `sets -renderable true -noSurfaceShader true -empty -n cdtGreenMedSG`;
connectAttr -f ($cdtGreenMed + ".outColor") ($cdtGreenMedSG + ".surfaceShader");
setAttr ($cdtGreenMed + ".color") 0 1 0;
} else { string $cdtGreenMedSG = "cdtGreenMedSG";}
if ($makeGreenDark == 1){
string $cdtGreenDark = `shadingNode -asShader lambert -n "cdtGreenDark"`;
string $cdtGreenDarkSG = `sets -renderable true -noSurfaceShader true -empty -n cdtGreenDarkSG`;
connectAttr -f ($cdtGreenDark + ".outColor") ($cdtGreenDarkSG + ".surfaceShader");
setAttr ($cdtGreenDark + ".color") 0 0.471 0;
} else { string $cdtGreenDarkSG = "cdtGreenDarkSG";}
if ($makeGrey == 1){
string $cdtGrey = `shadingNode -asShader lambert -n "cdtGrey"`;
string $cdtGreySG = `sets -renderable true -noSurfaceShader true -empty -n cdtGreySG`;
connectAttr -f ($cdtGrey + ".outColor") ($cdtGreySG + ".surfaceShader");
setAttr ($cdtGrey + ".color") 0.627 0.659 0.588;
} else { string $cdtGreySG = "cdtGreySG";}
if ($makeOrange == 1){
string $cdtOrange = `shadingNode -asShader lambert -n "cdtOrange"`;
string $cdtOrangeSG = `sets -renderable true -noSurfaceShader true -empty -n cdtOrangeSG`;
connectAttr -f ($cdtOrange + ".outColor") ($cdtOrangeSG + ".surfaceShader");
setAttr ($cdtOrange + ".color") 0.878431 0.560784 0.341176;
} else { string $cdtOrangeSG = "cdtOrangeSG";}
if ($makePurpLgt == 1){
string $cdtPurpLgt = `shadingNode -asShader lambert -n "cdtPurpLgt"`;
string $cdtPurpLgtSG = `sets -renderable true -noSurfaceShader true -empty -n cdtPurpLgtSG`;
connectAttr -f ($cdtPurpLgt + ".outColor") ($cdtPurpLgtSG + ".surfaceShader");
setAttr ($cdtPurpLgt + ".color") 0.549 0.392 0.412;
} else { string $cdtPurpLgtSG = "cdtPurpLgtSG";}
if ($makePurpDark == 1){
string $cdtPurpDark = `shadingNode -asShader lambert -n "cdtPurpDark"`;
string $cdtPurpDarkSG = `sets -renderable true -noSurfaceShader true -empty -n cdtPurpDarkSG`;
connectAttr -f ($cdtPurpDark + ".outColor") ($cdtPurpDarkSG + ".surfaceShader");
setAttr ($cdtPurpDark + ".color") 0.471 0.039 0.196;
} else { string $cdtPurpDarkSG = "cdtPurpDarkSG";}
if ($makeRedLgt == 1){
string $cdtRedLgt = `shadingNode -asShader lambert -n "cdtRedLgt"`;
string $cdtRedLgtSG = `sets -renderable true -noSurfaceShader true -empty -n cdtRedLgtSG`;
connectAttr -f ($cdtRedLgt + ".outColor") ($cdtRedLgtSG + ".surfaceShader");
setAttr ($cdtRedLgt + ".color") 0.878431 0.337255 0.337255;
} else { string $cdtRedLgtSG = "cdtRedLgtSG";}
if ($makeRedMed == 1){
string $cdtRedMed = `shadingNode -asShader lambert -n "cdtRedMed"`;
string $cdtRedMedSG = `sets -renderable true -noSurfaceShader true -empty -n cdtRedMedSG`;
connectAttr -f ($cdtRedMed + ".outColor") ($cdtRedMedSG + ".surfaceShader");
setAttr ($cdtRedMed + ".color") 1 0 0;
} else { string $cdtRedMedSG = "cdtRedMedSG";}
if ($makeTealLgt == 1){
string $cdtTealLgt = `shadingNode -asShader lambert -n "cdtTealLgt"`;
string $cdtTealLgtSG = `sets -renderable true -noSurfaceShader true -empty -n cdtTealLgtSG`;
connectAttr -f ($cdtTealLgt + ".outColor") ($cdtTealLgtSG + ".surfaceShader");
setAttr ($cdtTealLgt + ".color") 0 1 1;
} else { string $cdtTealLgtSG = "cdtTealLgtSG";}
if ($makeTealMed == 1){
string $cdtTealMed = `shadingNode -asShader lambert -n "cdtTealMed"`;
string $cdtTealMedSG = `sets -renderable true -noSurfaceShader true -empty -n cdtTealMedSG`;
connectAttr -f ($cdtTealMed + ".outColor") ($cdtTealMedSG + ".surfaceShader");
setAttr ($cdtTealMed + ".color") 0 0.471 0.471;
} else { string $cdtTealMedSG = "cdtTealMedSG";}
if ($makeWhite == 1){
string $cdtWhite = `shadingNode -asShader lambert -n "cdtWhite"`;
string $cdtWhiteSG = `sets -renderable true -noSurfaceShader true -empty -n cdtWhiteSG`;
connectAttr -f ($cdtWhite + ".outColor") ($cdtWhiteSG + ".surfaceShader");
setAttr ($cdtWhite + ".color") 1 1 1;
} else { string $cdtWhiteSG = "cdtWhiteSG";}
if ($makeYellow == 1){
string $cdtYellow = `shadingNode -asShader lambert -n "cdtYellow"`;
string $cdtYellowSG = `sets -renderable true -noSurfaceShader true -empty -n cdtYellowSG`;
connectAttr -f ($cdtYellow + ".outColor") ($cdtYellowSG + ".surfaceShader");
setAttr ($cdtYellow + ".color") 0.878431 0.878431 0.337255;
} else { string $cdtYellowSG = "cdtYellowSG";}
//Check and Reassign Lamberts
for ($lamb in $lamberts){
float $currColor[3] = `getAttr ($lamb + ".color")`;
//Beiges
if ((($currColor[0] >= 0.941) && ($currColor[0] <= 0.942))
&& (($currColor[1] >= 0.988) && ($currColor[1] <= 0.989))
&& (($currColor[2] >= 0.705) && ($currColor[2] <= 0.706))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtBeigeLgtSG $objShape;}}
else if ((($currColor[0] >= 0.784) && ($currColor[0] <= 0.785))
&& (($currColor[1] >= 0.823) && ($currColor[1] <= 0.824))
&& (($currColor[2] >= 0.588) && ($currColor[2] <= 0.589))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtBeigeMedSG $objShape;}}
else if ((($currColor[0] >= 0.549) && ($currColor[0] <= 0.550))
&& (($currColor[1] >= 0.576) && ($currColor[1] <= 0.577))
&& (($currColor[2] >= 0.411) && ($currColor[2] <= 0.412))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtBeigeDarkSG $objShapes;}}
//Blue
else if ((($currColor[0] >= 0.226) && ($currColor[0] <= 0.228))
&& (($currColor[1] >= 0.521) && ($currColor[1] <= 0.523))
&& (($currColor[2] >= 0.823) && ($currColor[2] <= 0.825))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtBlueSG $objShapes;}}
//Greens
else if ((($currColor[0] >= 0.337) && ($currColor[0] <= 0.338))
&& (($currColor[1] >= 0.878) && ($currColor[1] <= 0.879))
&& (($currColor[2] >= 0.337) && ($currColor[2] <= 0.338))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtGreenLgtSG $objShape;}}
else if (($currColor[0] == 0)
&& ($currColor[1] == 1)
&& ($currColor[2] == 0)){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtGreenMedSG $objShape;}}
else if (($currColor[0] == 0)
&& (($currColor[1] >= 0.470) && ($currColor[1] <= 0.472))
&& ($currColor[2] == 0)){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtGreenDarkSG $objShape;}}
//Grey
else if ((($currColor[0] >= 0.626) && ($currColor[0] <= 0.628))
&& (($currColor[1] >= 0.658) && ($currColor[1] <= 0.66))
&& (($currColor[2] >= 0.587) && ($currColor[2] <= 0.589))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtGreySG $objShape;}}
//Orange
else if ((($currColor[0] >= 0.878) && ($currColor[0] <= 0.879))
&& (($currColor[1] >= 0.560) && ($currColor[1] <= 0.561))
&& (($currColor[2] >= 0.341) && ($currColor[2] <= 0.342))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtOrangeSG $objShapes;}}
//Purples
else if ((($currColor[0] >= 0.548) && ($currColor[0] <= 0.55))
&& (($currColor[1] >= 0.391) && ($currColor[1] <= 0.393))
&& (($currColor[2] >= 0.411) && ($currColor[2] <= 0.413))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtPurpLgtSG $objShape;}}
else if ((($currColor[0] >= 0.470) && ($currColor[0] <= 0.472))
&& (($currColor[1] >= 0.038) && ($currColor[1] <= 0.04))
&& (($currColor[2] >= 0.195) && ($currColor[2] <= 0.197))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtPurpDarkSG $objShape;}}
//Reds
else if ((($currColor[0] >= 0.878) && ($currColor[0] <= 0.879))
&& (($currColor[1] >= 0.337) && ($currColor[1] <= 0.338))
&& (($currColor[2] >= 0.337) && ($currColor[2] <= 0.338))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtRedLgtSG $objShape;}}
else if ((($currColor[0] >= 0.699) && ($currColor[0] <= 0.701))
&& (($currColor[1] >= 0.299) && ($currColor[1] <= 0.301))
&& (($currColor[2] >= 0.299) && ($currColor[2] <= 0.301))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtRedLgtSG $objShape;}}
else if (($currColor[0] == 1)
&& ($currColor[1] == 0)
&& ($currColor[2] == 0)){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtRedMedSG $objShape;}}
//Teals
else if (($currColor[0] == 0)
&& ($currColor[1] == 1)
&& ($currColor[2] == 1)){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtTealLgtSG $objShape;}}
else if ((($currColor[0] >= 0) && ($currColor[0] <= 0.001))
&& (($currColor[1] >= 0.470) && ($currColor[1] <= 0.472))
&& (($currColor[2] >= 0.470) && ($currColor[2] <= 0.473))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtTealMedSG $objShape;}}
//White
else if (($currColor[0] == 1)
&& ($currColor[1] == 1)
&& ($currColor[2] == 1)){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtWhiteSG $objShape;}}
//Yellows
else if ((($currColor[0] >= 0.878) && ($currColor[0] <= 0.879))
&& (($currColor[1] >= 0.878) && ($currColor[1] <= 0.879))
&& (($currColor[2] >= 0.337) && ($currColor[2] <= 0.338))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtYellowSG $objShape;}}
else if ((($currColor[0] >= 0.699) && ($currColor[0] <= 0.701))
&& (($currColor[1] >= 0.699) && ($currColor[1] <= 0.701))
&& (($currColor[2] >= 0.299) && ($currColor[2] <= 0.301))){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement cdtYellowSG $objShape;}}
//initialShadingGroup
else if (($currColor[0] == 0.5)
&& ($currColor[1] == 0.5)
&& ($currColor[2] == 0.5)){
select -r $lamb;
hyperShade -objects "";
string $objShapes[] = `ls -sl`;
for ($objShape in $objShapes){
sets -edit -forceElement initialShadingGroup $objShape;}}
}
hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes");
}