//James Parks //07-14-2004 //jpAutoClusterCurve_v1.1.mel global proc jpACCurve(int $manipulatorType, int $controlType, int $groupThings) { string $selectedObjs[] = `ls -sl`; string $createdControls[]; string $createdClusters[]; for($selectedCurve in $selectedObjs) { if($manipulatorType ==3) if($selectedCurve == $selectedObjs[`size($selectedObjs)` - 1]) break; string $objType = "nurbsCurve"; if($objType == "nurbsCurve") { int $spanCount = `getAttr ($selectedCurve + ".spans")`; int $degCount = `getAttr ($selectedCurve + ".degree")`; int $cvCount = $spanCount + $degCount; for($i=0; $i< $cvCount; $i++) { cluster ($selectedCurve + ".cv[" + $i + "]"); string $clustName[] = `ls -sl`; switch($manipulatorType) { case 1: string $locName[] = `spaceLocator`; break; case 2: string $locName[] = `circle -c 0 0 0 -nr 0 0 1 -r 1 -s 8`; break; case 3: int $numberOfObjs = `size($selectedObjs)`; string $locName[] = `duplicate $selectedObjs[$numberOfObjs - 1]`; break; default: warning "An Error has occured: Manipulator Type"; break; }//end switch //place locator on top of cluster select $clustName[0] $locName[0]; string $point[] = `pointConstraint -n tempPoint -weight 1`; string $orient[] = `orientConstraint -n tempOrient -weight 1`; string $scale[] = `scaleConstraint -n tempScale -weight 1`; //cleanup select $point[0] $orient[0] $scale[0]; delete; switch($controlType) { case 1: parent $clustName[0] $locName[0]; break; case 2: string $point[] = `pointConstraint -weight 1 $locName[0] $clustName[0]`; break; case 3: connectAttr ($locName[0] + ".t") ($clustName[0] + ".t"); break; default: warning "An Error has occured: Control Type"; }//end switch select $locName[0]; FreezeTransformations; setAttr ($clustName[0] + ".visibility") 0; switch($manipulatorType) { case 1: $locName[0] = `rename $locName[0] ($selectedCurve + "_clusterLoc_" + $i)`; break; case 2: $locName[0] = `rename $locName[0] ($selectedCurve + $i + "_CTRL" )`; break; case 3: $locName[0] = `rename $locName[0] ($selectedCurve + $i + "_CTRL")`; break; default: warning "An Error has occured: manipulator renaming"; break; }//end switch $createdControls[$i] = $locName[0]; $createdClusters[$i] = $clustName[0]; }//end for: all CVs if($groupThings == 1) { select $createdControls; group -n ($selectedCurve + "_controls"); if($controlType != 1) { select $createdClusters; group -n ($selectedCurve + "_clusters"); } }//end if }//end if: is curve else { warning "No NURBS curves selected"; }//end else }//end for:all objects }//end proc jpAutoClusterCurve global proc jpAutoClusterCurve() { string $winName = "jpAutoClusterCurve"; if (`window -exists $winName`) deleteUI $winName; window -t "Auto Cluster Curve v1.1" -wh 200 70 -rtf 1 $winName; rowColumnLayout -nc 1 -w 210 -cw 1 210; text -label "Manipulator Type"; radioButtonGrp -w 300 -h 25 -nrb 3 -cw 1 60 -cw 2 50 -cw 3 100 -cal 1 "left" -cal 2 "left" -cal 3 "left" -l1 "Locator" -l2 "Circle" -l3 "Last Selected" -sl 2 manipulatorType; text -label "Control Type"; radioButtonGrp -w 300 -h 25 -nrb 3 -cw 1 60 -cw 2 75 -cw 3 60 //-cal 1 "left" //-cal 2 "left" -l1 "Parent" -l2 "Constrain" -l3 "Connect" -sl 1 parentConstrainGrp; checkBoxGrp -ncb 1 -label "Group Results" groupResultsGrp; button -w 50 //-al "left" -l "Clusterize" -c "jpACCurve(`radioButtonGrp -q -sl manipulatorType`,`radioButtonGrp -q -sl parentConstrainGrp`,`checkBoxGrp -q -v1 groupResultsGrp`)" clusterizeButton; showWindow $winName; }//end proc jpAutoClusterCurveGUI //jpAutoClusterCurveGUI