# Joint Controller Orientation

**URL:** https://forum.highend3d.com/t/joint-controller-orientation/47336
**Category:** Maya
**Tags:** rigging-character
**Created:** [May 13, 2016, 6:41am UTC](https://forum.highend3d.com/t/joint-controller-orientation/47336 "2016-05-13T06:41:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nathan\_warford](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nathan\_warford](https://forum.highend3d.com/u/nathan_warford)
#### Post date: [May 13, 2016, 6:41am UTC](https://forum.highend3d.com/t/joint-controller-orientation/47336/1 "2016-05-13T06:41:22Z")

</div>

I am almost done creating a rigged character. All of the joints are in place, the Joint Orient axes are aimed in the right directions, and all of the skinning is completed. All I have to do is apply controllers to the joints. Naturally, when I orient a controller to a joint, its rotational axes are no longer 0,0,0. I can freeze transformations, but when I do that, the rotational axes of the controller become oriented to the World instead of the joint.

Getting the rotational axes of the joints is easy because all you have to do is change the Joint Orient values. Is there are similar tool for woking with NURBS so that the rotational axes are not aligned with the World but still read as 0,0,0?

---

<div class="post-metadata">

### Author: ![charliewales](https://forum.highend3d.com/user_avatar/forum.highend3d.com/charliewales/32/4_2.png) [@charliewales](https://forum.highend3d.com/u/charliewales)
#### Post date: [May 18, 2016, 1:38am UTC](https://forum.highend3d.com/t/joint-controller-orientation/47336/2 "2016-05-18T01:38:07Z")

</div>

You have to group the controls, put the control values in the parent group and reset the control. This script does this automatically.

[Script to orient controls in Maya](http://3danimatedcharacters.com/script-to-orient-controls-in-maya/)

“”"  
This script creates spaces for all selected objects.  
If those are orientated controls, then script will  
zero them out and transfer their rotations, translations  
scales to their parent group  
“”"

import maya.cmds as cmds

def match\_second\_to\_first(first, sec):  
&nbsp;&nbsp;&nbsp; “”"  
&nbsp;&nbsp;&nbsp; matches second position and rotation to the  
&nbsp;&nbsp;&nbsp; first position and rotation  
&nbsp;&nbsp;&nbsp; “”"  
&nbsp;&nbsp;&nbsp; cns = cmds.parentConstraint(first, sec)  
&nbsp;&nbsp;&nbsp; cmds.delete(cns)  
&nbsp;&nbsp; &nbsp;  
def scale\_sec\_like\_first(first, sec):  
&nbsp;&nbsp;&nbsp; “”"  
&nbsp;&nbsp;&nbsp; matches second scaling to first scaling  
&nbsp;&nbsp;&nbsp; “”"  
&nbsp;&nbsp;&nbsp; cns = cmds.scaleConstraint(first, sec)  
&nbsp;&nbsp;&nbsp; cmds.delete(cns)

def make\_space\_for(the\_object, suffix):  
&nbsp;&nbsp;&nbsp; “”"  
&nbsp;&nbsp;&nbsp; this function makes space for selected control  
&nbsp;&nbsp;&nbsp; object based on the provided suffix  
&nbsp;&nbsp;&nbsp; “”"

# this is to make sure that space name doesnt already exist:  
&nbsp;&nbsp;&nbsp; GRP = “”  
&nbsp;&nbsp;&nbsp; if cmds.objExists(the\_object+“\_”+suffix):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 0

# we are looping “i” until we find name that is not used  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while cmds.objExists(the\_object+“\_”+suffix+str(i)):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i += 1

cmds.warning("default space name is taken, "  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "the object might already have "  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “a space, adding number suffix”)

GRP = cmds.group(empty=True,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name=the\_object+“\_”+suffix+str(i))  
&nbsp;&nbsp;&nbsp; else:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GRP = cmds.group(empty=True,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name=the\_object+“\_”+suffix)

the\_parent = cmds.listRelatives(the\_object, parent=True)

if the\_parent is not None:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmds.parent(GRP, the\_parent[0])  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmds.parent(the\_object, world=True)

match\_second\_to\_first(the\_object, GRP)  
&nbsp;&nbsp;&nbsp; scale\_sec\_like\_first(the\_object, GRP)

cmds.parent(the\_object, GRP)

match\_second\_to\_first(GRP, the\_object)  
&nbsp;&nbsp;&nbsp; scale\_sec\_like\_first(GRP, the\_object)

try:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmds.makeIdentity(the\_object, apply=True,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t=1, r=1, s=1, n=0)  
&nbsp;&nbsp;&nbsp; except:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmds.warning("Cannot freeze transformations for: "+  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + the\_object + “, is it skinned or connected?”)

return(GRP)

# this loop below loops through selection and  
# creates spaces for each selected object/control  
for obj in cmds.ls(selection=True):  
&nbsp;&nbsp;&nbsp; make\_space\_for(obj, “grp”)

---

<div class="post-metadata">

### Author: ![nathan\_warford](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nathan\_warford](https://forum.highend3d.com/u/nathan_warford)
#### Post date: [May 20, 2016, 8:03pm UTC](https://forum.highend3d.com/t/joint-controller-orientation/47336/3 "2016-05-20T20:03:34Z")

</div>

I had come to realize that it required creating a group for each controller, but I never knew that there was a script to do the job for me. Thank you for the reply. I tried out the script and it made things ten times easier.

---

<div class="post-metadata">

### Author: ![crisosphinx](https://forum.highend3d.com/user_avatar/forum.highend3d.com/crisosphinx/32/28_2.png) [@crisosphinx](https://forum.highend3d.com/u/crisosphinx)
#### Post date: [May 24, 2016, 6:18am UTC](https://forum.highend3d.com/t/joint-controller-orientation/47336/4 "2016-05-24T06:18:18Z")

</div>

“but I never knew that there was a script to do the job for me”  
&nbsp;  
It’s pretty easy to script these types of things after studying MELscript and Python/PyMel for a little while. I suggest you invest a little time into learning a bit. It’ll totally make your life easier Nathan! 😃 &nbsp;You can automate most tasks in Maya with a few button clicks, after you’ve learned how to script the commands.
