MEL script

Just finished a DT MEL kit..

global proc flowerMaker() {

int $numPetals = 10;
$createShader = 1;

//////////////////////////////////////////////

//check for shader
string $shads[] = `ls -mat`;
for ($myNode in $shads) {
if ($myNode == “petalColor”)
$createShader = 0;
}

switch ($createShader) {
case 0:
print “the shader is already there\n”;
break;
case 1:
//build the shader network
shadingNode -asShader lambert -n “petalColor”;
shadingNode -asTexture ramp -n “petalRamp”;
sets -renderable true -noSurfaceShader true -empty -n petalColorSG;
connectAttr -f petalColor.outColor petalColorSG.surfaceShader;

//create core shader
shadingNode -asShader lambert -n “petalCore”;
setAttr “petalCore.color” -type double3 0.4 0.2 0.14;
sets -renderable true -noSurfaceShader true -empty -n petalCoreSG;

connectAttr -f petalCore.outColor petalCoreSG.surfaceShader;
connectAttr petalRamp.outColor petalColor.color;
setAttr “petalRamp.colorEntryList[3].color” -type double3 1 0 0;
setAttr “petalRamp.colorEntryList[3].position” 1;
setAttr “petalRamp.colorEntryList[2].color” -type double3 1 1 0;
setAttr “petalRamp.colorEntryList[2].position” .5;
setAttr “petalRamp.colorEntryList[1].color” -type double3 1 0 0;
setAttr “petalRamp.colorEntryList[1].position” 0;
setAttr petalRamp.type 8;

break;
}

//create flower core
sphere -ax 0 1 0 -n “core”;
string $myCore[] = `ls -sl`;
scale 1 .5 1;
move 0 .2 0;
pickWalk -d down;
string $myCoreShape[] = `ls -sl`;
sets -edit -forceElement petalCoreSG $myCoreShape[0];

//build petal
sphere – ax 0 1 0;
move 0 0 -1.6;
scale .7 .3 1.7;
FreezeTransformations;
ResetTransformations;
string $myPetal[] = `ls -sl`;
parent $myPetal $myCore;
//connect to the shader network
select $myPetal;
pickWalk -d down;
string $myPetalShape[] = `ls -sl`;
sets -edit -forceElement petalColorSG $myPetalShape[0];

//move the tip of the pedal
select ($myPetal[0] +”.cv[3][7]“);
move -r 0 2 0;

//push down CV’s loop
//one loop for the U direction
for ($uCV = 5; $uCV <= 6; $uCV++) {

for ($vCV = 0; $vCV <= 7; $vCV++) {
select ($myPetal[0] +”.cv[" +$uCV +"]["+$vCV+"]“);
move -r 0 -.3 0;
}}
select $myPetal[0];
float $degreeApart = (360 / $numPetals);
print $degreeApart;

for ($i = 2;$i <= $numPetals; $i++) {
duplicate;
rotate -r 0 $degreeApart 0;

}

select $myCore;
rename “Flower0″;
}

—————–

That’s all fancy talk for this: