/////////////////////////////////////////////////// // slaveSkel.mel // // Sean Nolan // sean@snolan.net // // Connect duplicated skeleton to existing rig // Usage: // Select duplicated skeleton root then original. /////////////////////////////////////////////////// global proc slaveSkel() { if(`window -ex slaveSkelWin`) deleteUI slaveSkelWin; window -title "Slave Skeleton" slaveSkelWin; int $winH = 180; int $winW = 220; columnLayout; text -l "Select Duplicated Skeleton"; rowColumnLayout -nc 2 -cw 1 100 -cw 2 100; textField -w 200 txtDupSkel; button -l "Select" -command firstSel; setParent..; setParent..; text -l "Select Original Skeleton"; rowColumnLayout -nc 2 -cw 1 100 -cw 2 100; textField -w 200 txtOrgSkel; button -l "Select" -command secSel; text -l "Connect Attributes";text -l ""; checkBox -l "Translate" ckTrans; checkBox -l "Rotate" ckRot; checkBox -l "Maintain Offest" ckTransOffset; checkBox -l "Maintain Offest" ckRotOffset; button -l "Connect Skeletons" -command connectSkeleton; button -l "Close" -command "deleteUI slaveSkelWin"; window -e -wh $winW $winH slaveSkelWin; showWindow slaveSkelWin; } global proc firstSel() { string $sel[] = `ls -sl`; textField -e -tx $sel[0] txtDupSkel; } global proc secSel() { string $sel[] = `ls -sl`; textField -e -tx $sel[0] txtOrgSkel; } global proc connectSkeleton() { select -cl; int $i; string $dupTxt = `textField -q -tx txtDupSkel`; string $orgTxt = `textField -q -tx txtOrgSkel`; string $selHiDup[] = `select -hi $dupTxt`; string $dupJointSelection[] = `ls -sl -type "joint"`; select -cl; string $selHiOrg[] = `select -hi $orgTxt`; string $orgJointSelection[] = `ls -sl -type "joint"`; select -cl; int $numOfDupJoints = `size($dupJointSelection)`; int $numOfOrgJoints = `size($orgJointSelection)`; int $connectTrans = `checkBox -q -v ckTrans`; int $connectRot = `checkBox -q -v ckRot`; int $checkTransOffset = `checkBox -q -v ckTransOffset`; int $checkRotOffset = `checkBox -q -v ckRotOffset`; //check number of joints if($numOfDupJoints != $numOfOrgJoints) { if($numOfDupJoints < $numOfOrgJoints) { error "Orignal Skeleton has more joints. Reselect Orginal root."; } if($numOfDupJoints > $numOfOrgJoints) { error "Duplicated Skeleton has more joints. Reselect duplicated root."; } } for($i = 0; $i < $numOfDupJoints; $i++) { if($connectTrans == 1) {//check offset if($checkTransOffset == 1) { pointConstraint -mo $orgJointSelection[$i] $dupJointSelection[$i]; } else { pointConstraint $orgJointSelection[$i] $dupJointSelection[$i]; } } if($connectRot == 1) { if($checkRotOffset == 1) { orientConstraint -mo $orgJointSelection[$i] $dupJointSelection[$i]; } else { orientConstraint $orgJointSelection[$i] $dupJointSelection[$i]; } } } }