Home Technical Talk

MEL - Naming a bend as it's being created?

polycounter lvl 14
Offline / Send Message
mdeforge polycounter lvl 14
Hey guys,

I'm trying to give a name to each bend being created by a MEL script so it doesn't cause trouble with other bends in the scene. The script below basically takes a bandaid (the bandaid part and the two tabs on either side you pull off) and applies four bends to it so you can peel them away realistically. I've done it manually for about a month now and it works great, but I'm so ready for this process to be automated.
global proc theBendz()
{
// Check to see if the main window is already open
if (`window -ex mainWin` != true)
{
// Set main window attributes
window -w 310 -h 256 -t ("theBendz") -in "theBendz" -s true -tb true mainWin;

formLayout mainForm;
separator -style "in" -h 3 sep0;
button -l "Bend it!" -al "center" -c ("apply();") -ann ("Apply the bends") btnOJ;
separator -style "double" -h 7 sepBig;
iconTextButton -style "textOnly" -l ("e-mail") -ann ("theBendz") -c ("showHelp -a \"meh website\"") -h 24 email;
formLayout -e
-af sep0 "left" 0
-af sep0 "right" 0
-af sep0 "top" 0
-an sep0 "bottom"
-af btnOJ "left" 5
-af btnOJ "right" 5
-af btnOJ "top" 5
-an btnOJ "bottom"
-af email "left" 0
-af email "right" 0
-ac email "top" 0 btnOJ
-an email "bottom"
mainForm;
showWindow mainWin;
}
}
global proc apply()
{
print ("// theBendz\n");
// Get list of what is selected
string $select[] = `ls -sl`;
// Apply the first bend to the MD and the left wing
select -r $select[0];
select -tgl $select[1];
nonLinear -type bend -name "MD_LeftWing" -lowBound 0 -highBound 1 -curvature 0.0;
// bend1 bend1Handle //
rotate -r -os 0 90 0 ;
rotate -r -os 0 0 90 ;
 
// Apply the second bend to the MD and the right wing
select -r $select[0];
select -tgl $select[2];
nonLinear -type bend -name "MD_RightWing" -lowBound 0 -highBound 1 -curvature 0.0;
// bend2 bend2Handle //
rotate -r -os 0 -90 0 ;
rotate -r -os 0 0 90 ;
// Apply the third bend to the left wing
select -r $select[1];
nonLinear -type bend -name "LeftWing" -lowBound 0 -highBound 1 -curvature 3.14;
// bend3 bend3Handle //
select -addFirst bend3;
rotate -r -os 0 90 0 ;
rotate -r -os 0 0 -90 ;
setAttr "bend3Handle.scaleX" .008;
setAttr "bend3Handle.scaleY" .008;
setAttr "bend3Handle.scaleZ" .008;
// Apply the fourth bend to the right wing
select -r $select[2];
nonLinear -type bend -name "RightWing" -lowBound 0 -highBound 1 -curvature 3.14;
// bend4 bend4Handle //
select -addFirst bend4;
rotate -r -os 0 90 0 ;
rotate -r -os 0 0 -90 ;
setAttr "bend4Handle.scaleX" .008;
setAttr "bend4Handle.scaleY" .008;
setAttr "bend4Handle.scaleZ" .008;
}

As you can see, the referencing of the bends is even hardcoded in there...

I've tried naming them, as you see above, but it doesn't work... no errors are thrown, but the same old Bend1, Bend1HandleShape and Bend1Handle is created.

Can anyone share their expertise with me? Or at least point me somewhere that I may be able to dig? I've done a lot of searching but keep seeing the same information (or lack thereof).
Sign In or Register to comment.