MEL Perfectly Orients 3-Joint Chain
Here’s a MEL script that can create a perfectly oriented 3-joint chain. The orient joint tool in Maya has some limitations and manually orienting with aimConstraints is ideal but time-consuming. Hope this script saves you some time (it saves me a lot of time). Cheers!
/* ------------------------------- PERFECTLY ORIENTS 3-JOINT CHAIN ------------------------------- FUNCTION 1. Creates perfectly oriented 3-joint chain PRE-REQUISITES 1. Must be a parented 3-joint chain HOW TO USE 1. Select top joint in 3-joint hierachy 2. rf_3jntChain(); RELEASE DATE / AUTHOR 1. 22 JAN 2014 / RONALD FONG */ global proc rf_3jntChain(){ // declare selection $head = `ls -sl`; $mid = `listRelatives -c $head`; $end = `listRelatives -c $mid`; // unparent parent -w $end; parent -w $mid; // orient using aim MID HEAD select -r $mid $head ; aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "object" -worldUpObject $end; // orient using aim END MID select -r $end $mid ; aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "object" -worldUpObject $head; // delete aim constraints delete ($mid[0] + "_aimConstraint1"); delete ($head[0] + "_aimConstraint1"); // freeze select -r $head $mid $end; FreezeTransformations; // parent parent $end $mid; parent $mid $head; // zeroEnd setAttr ($end[0] + ".jointOrient") 0 0 0; // prompt check print "Check Local Rotation Axes!"; } rf_3jntChain();