//-------------------------------------------- // script: snInsertJoint.mel // // Author: Sean Nolan // sean@snolan.net // // Usage: Creates a joint insert with an // interactive slider for its // x tranlation value. // // Select the joint where you want the insert. Run Script //-------------------------------------------- global proc snInsertJoint() { string $checkForBone[] = `ls -sl -type "joint"`; //make sure a joint is selected if($checkForBone[0] == "") error("Select a joint"); if(`window -ex snInsertJointWin`) deleteUI snInsertJointWin; window -title "Interactive Joint Insert" snInsertJointWin; columnLayout; string $newJoint[] = `ls -sl`; string $getNextBoneName[] = `listRelatives -type "joint"`; float $nextBoneVal = `getAttr ($getNextBoneName[0] + ".tx")`; text -l "New Joint Name"; nameField -w 100 -object $newJoint[0]; text -l "New Joint Position"; floatSlider -minValue -0 -maxValue $nextBoneVal -dragCommand "updateJoint($newJoint[0])" -w 225 slider; setParent..; rowColumnLayout -nc 3 -cw 1 75 -cw 2 75 -cw 3 75; button -label "Remove Joint" -command "removeJoint"; button -label "Insert" -command "insertJoint; string $newJoint[] = `ls -sl`; snInsertJoint()"; button -label "Close" -command "deleteUI snInsertJointWin"; button -label "25%" -command "insertQuarterway($newJoint[0])"; button -label "50%" -command "insertHalfway($newJoint[0])"; button -label "75%" -command "insertThreeQuarterway($newJoint[0])"; setParent..; rowColumnLayout -nc 3 -cw 1 50 -cw 2 120 -cw 3 75; text -l ""; button -label "Indepedent Insert" -command "indepedentInsert()"; window -e -w 235 snInsertJointWin; showWindow snInsertJointWin; } //updates the joint position based off the slider global proc updateJoint(string $joint) { float $val = `floatSlider -q -v slider`; joint -edit -r -p $val 0 0 -component $joint; } //force the joint and slider to halfway point global proc insertHalfway(string $j) { // zero joints x translation joint -edit -r -p 0 0 0 -component $j; string $getNextBoneName[] = `listRelatives -type "joint"`; //get the next bones x value float $boneNextVal = `getAttr ($getNextBoneName[0] + ".tx")`; //edit the slider and joint floatSlider -e -value ($boneNextVal * 0.5) slider; updateJoint($j); } //force the joint and slider to quarter way point global proc insertQuarterway(string $j) { // zero joints x translation joint -edit -r -p 0 0 0 -component $j; string $getNextBoneName[] = `listRelatives -type "joint"`; //get the next bones x value float $boneNextVal = `getAttr ($getNextBoneName[0] + ".tx")`; //edit the slider and joint floatSlider -e -value ($boneNextVal * 0.25) slider; updateJoint($j); } //force the joint and slider to three quarter way point global proc insertThreeQuarterway(string $j) { // zero joints x translation joint -edit -r -p 0 0 0 -component $j; string $getNextBoneName[] = `listRelatives -type "joint"`; //get the next bones x value float $boneNextVal = `getAttr ($getNextBoneName[0] + ".tx")`; //edit the slider and joint floatSlider -e -value ($boneNextVal * 0.75) slider; updateJoint($j); } //creates an independent insert that will not drive the child joints //best for arms global proc indepedentInsert() { string $new[] = `ls -sl`; string $nextBone[] = `listRelatives -type "joint"`; pickWalk -d up; string $prevBone[] = `ls -sl`; select -r $new[0]; //unparent the selected on and the next one parent -w $new; parent -w $nextBone; //parent the next bone to the previous //parent the new bone back to the previous parent -a $nextBone $prevBone; parent -a $new $prevBone; };