MEL Script to create controller at a single selected joint

/*
-----------------------------
CREATE CTRL AT SELECTED JOINT
-----------------------------
Function: Creates a controller at the joint select with the suffix "_Ctrl"

How to use:
1. Source rf_jnt2ctrl.mel
2. Select a joint
3. rf_jnt2ctrl();

Possible improvements:
1. Application on multiple joints
2. User input for controller size

Date released: 04 June 2013
Created by Ronald Fong
*/

global proc rf_jnt2ctrl(){

//DEFINE VARIABLES 1. JNT 2. CTRL
$jnt = `ls -sl`;
$ctrlSize = 1;
circle -n ($jnt[0] + "_Ctrl") -c 0 0 0 -nr 0 1 0 -sw 360 -r $ctrlSize -d 3 -ut 0 -tol 0.01 -s 8 -ch 1; objectMoveCommand;
$ctrl = $jnt[0] + "_Ctrl";


//MOVE CTRL TO JNT POS
select -r $jnt $ctrl;
doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
parentConstraint -weight 1;

//DELETE RE-POS PARENT CONSTRAINT
delete ($ctrl + "_parentConstraint1") ;

//FREEZE + DEL HIST CTRL
select -r $ctrl;
FreezeTransformations;
DeleteHistory;

//CTRL TO CONTROL JNT
select -r $ctrl $jnt ;
doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
parentConstraint -mo -weight 1;
}

//rf_jnt2ctrl();
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *