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
"""
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):
"""
matches second position and rotation to the
first position and rotation
"""
cns = cmds.parentConstraint(first, sec)
cmds.delete(cns)
def scale_sec_like_first(first, sec):
"""
matches second scaling to first scaling
"""
cns = cmds.scaleConstraint(first, sec)
cmds.delete(cns)
def make_space_for(the_object, suffix):
"""
this function makes space for selected control
object based on the provided suffix
"""
# this is to make sure that space name doesnt already exist:
GRP = ""
if cmds.objExists(the_object+"_"+suffix):
i = 0
# we are looping "i" until we find name that is not used
while cmds.objExists(the_object+"_"+suffix+str(i)):
i += 1
cmds.warning("default space name is taken, "
"the object might already have "
"a space, adding number suffix")
GRP = cmds.group(empty=True,
name=the_object+"_"+suffix+str(i))
else:
GRP = cmds.group(empty=True,
name=the_object+"_"+suffix)
the_parent = cmds.listRelatives(the_object, parent=True)
if the_parent is not None:
cmds.parent(GRP, the_parent[0])
cmds.parent(the_object, world=True)
match_second_to_first(the_object, GRP)
scale_sec_like_first(the_object, GRP)
cmds.parent(the_object, GRP)
match_second_to_first(GRP, the_object)
scale_sec_like_first(GRP, the_object)
try:
cmds.makeIdentity(the_object, apply=True,
t=1, r=1, s=1, n=0)
except:
cmds.warning("Cannot freeze transformations for: "+
+ 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):
make_space_for(obj, "grp")