Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ns = cmds.ls("Hattie*:Geo_Grp")[0].split(":")[0]
- angle_calc_joints= {':{side}_Arm_ShoulderSecondaryA_Bind_Jnt':'start',
- ':{side}_Arm_ShoulderSecondaryF_Bind_Jnt':'middle',
- ':{side}_Arm_ElbowSecondaryF_Bind_Jnt':'end'}
- dist_start_joints = [
- ':{side}_Cuff_Part_Bind_Jnt',
- ':{side}_Cuff02_Part_Bind_Jnt',
- ':{side}_Cuff03_Part_Bind_Jnt',
- ':{side}_Cuff04_Part_Bind_Jnt'
- ]
- dist_end_joint = ':{side}_Arm_ShoulderSecondaryD_Bind_Jnt'
- cuff_center_joint = ':{side}_CuffElbowTwist_Part_Bind_Jnt'
- loc_offset_dict = {u'{ns}__L_Cuff02_cuff_dist_end_pt.r': (-13.710952036971118,
- -0.1653287205299997,
- -2.002178735393707),
- u'{ns}__L_Cuff02_cuff_dist_end_pt.t': (0.8669128896274074,
- 0.5791167822250358,
- 6.082250686357249),
- u'{ns}__L_Cuff03_cuff_dist_end_pt.r': (-5.53661791560965,
- 1.2498842488794155,
- 15.317549823010165),
- u'{ns}__L_Cuff03_cuff_dist_end_pt.t': (5.428926926507209,
- 0.4935049443176567,
- 0.5076109457532234),
- u'{ns}__L_Cuff04_cuff_dist_end_pt.r': (6.719219366751352,
- 0.14837106877796996,
- 1.7967444886748256),
- u'{ns}__L_Cuff04_cuff_dist_end_pt.t': (0.800522067964657,
- -0.288305247764999,
- -4.804874309085163),
- u'{ns}__L_Cuff_cuff_dist_end_pt.r': (-4.720192471964436,
- -0.4797406481189684,
- -18.611451547690617),
- u'{ns}__L_Cuff_cuff_dist_end_pt.t': (-4.78674468822242,
- 0.7691870091930397,
- 1.4424614781989653),
- u'{ns}__R_Cuff02_cuff_dist_end_pt.r': (-13.710952036971118,
- 0.1653287205299997,
- 2.002178735393707),
- u'{ns}__R_Cuff02_cuff_dist_end_pt.t': (-0.8669128896274003,
- 0.5791167822250323,
- 6.0822506863572485),
- u'{ns}__R_Cuff03_cuff_dist_end_pt.r': (-5.53661791560965,
- -1.2498842488794164,
- -15.317549823010188),
- u'{ns}__R_Cuff03_cuff_dist_end_pt.t': (-5.428926926507209,
- 0.493504944317646,
- 0.507610945753224),
- u'{ns}__R_Cuff04_cuff_dist_end_pt.r': (6.719219366751352,
- -0.14837106877797157,
- -1.7967444886748256),
- u'{ns}__R_Cuff04_cuff_dist_end_pt.t': (-0.8005220679646428,
- -0.28830524776500965,
- -4.8048743090851636),
- u'{ns}__R_Cuff_cuff_dist_end_pt.r': (-4.720192471964439,
- 0.47974064811896816,
- 18.611451547690592),
- u'{ns}__R_Cuff_cuff_dist_end_pt.t': (4.786744688222427,
- 0.7691870091930255,
- 1.4424614781989658)}
- #replace dictionary keys with prpoer namespace
- for k in loc_offset_dict:
- loc_offset_dict[k.format(ns=ns)] = loc_offset_dict.pop(k)
- for side in ['L','R']:
- #create locator on upper arm
- endJoint_loc = cmds.spaceLocator(n=ns+'__'+side+'_cuff_dist_end_pt')[0]
- #create an attr for controlling how much auto offset to apply
- if not cmds.objExists(ns+':'+side+'_CuffElbowTwist_Main_Ctrl.autoY_offset'):
- cmds.addAttr(ns+':'+side+'_CuffElbowTwist_Main_Ctrl',longName='autoY_offset',at='float',k=1)
- #create locator on center of cuff
- collar_center_loc = cmds.spaceLocator(n=ns+'__'+side+'_cuff_center')[0]
- for jnt in dist_start_joints:
- print jnt.format(side=side)
- #get cuff parts string from joint name
- cuff_part = jnt.split('_')[1]
- #create distance nodes
- cmds.createNode('distanceDimShape')
- dist_node_name = ns+'_'+side+'_'+cuff_part+'_distancer'
- dist_dim = cmds.rename(cmds.listRelatives(p=1)[0],dist_node_name)
- #create offset loc for default position of cuff joints
- #locs are parented to the center cuff loc
- startJoint_loc = cmds.spaceLocator(n=ns+'__'+side+'_'+cuff_part+'_cuff_dist_end_pt')[0]
- cmds.parent(startJoint_loc,collar_center_loc)
- #apply pre-defined transform values to the locators
- for tr in ['t','r']:
- val_get = loc_offset_dict[startJoint_loc+'.'+tr]
- cmds.setAttr(startJoint_loc+'.'+tr,val_get[0],val_get[1],val_get[2])
- #create a second set of cuff locators in world space for world location
- startJoint_world_loc = cmds.spaceLocator(n=ns+'__'+side+'_'+cuff_part+'_cuff_dist_end_pt_world')[0]
- cmds.parentConstraint(startJoint_loc,startJoint_world_loc)
- #connect the upper arm loc and the world cuff loc to the distance node
- cmds.connectAttr(startJoint_world_loc+'.t',dist_dim+'.startPoint')
- cmds.connectAttr(endJoint_loc +'.t',dist_dim+'.endPoint')
- #define the expression for autooffset
- expn_struct = ns+':{side}_{part}_Main_Cns.ty = {distancer}*{yoffset}'.format(
- side=side,
- part=cuff_part,
- distancer=dist_dim+'.distance',
- yoffset=ns+':'+side+'_CuffElbowTwist_Main_Ctrl.autoY_offset'
- )
- #create expressions
- #cmds.expression(s=expn_struct,n='expn_autoY_'+cuff_part)
- cmds.parentConstraint(ns+cuff_center_joint.format(side=side),collar_center_loc)
- cmds.parentConstraint(ns+dist_end_joint.format(side=side),endJoint_loc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement