def YJ_Arm_Fk_shape(Arm_Fk_name):
YJ_Creat_Ctrl(4,'CircleCurve')
select ('CircleCurve.cv[0:7]',r=1)
rotate (0,0,90,r=1,p=('0cm','0cm','0cm'),os=1)
select ('CircleCurve',r=1)
select (Arm_Fk_name,add=1)
YJ_Parent_Shape()
YJRigZeroGrp([Arm_Fk_name])
def YJ_HumanArmRig_FK(ArmSide):
select ('%s_upArm_Bone'%ArmSide,r=1)
duplicate(rr=1,rc=1)
YJ_SearchReplace_name('Bone1','FK')
YJ_Arm_Fk_shape('%s_upArm_FK'%ArmSide)
YJ_Arm_Fk_shape('%s_lowArm_FK'%ArmSide)
YJ_Arm_Fk_shape('%s_hand_FK'%ArmSide)
def YJ_HumanArmRig_IK(ArmSide):
select ('%s_upArm_Bone'%ArmSide,r=1)
duplicate(rr=1,rc=1)
YJ_SearchReplace_name('Bone1','IK')
setAttr('%s_lowArm_IK.rotateY'%ArmSide,-45)
joint('%s_lowArm_IK'%ArmSide,e=1 ,spa=1,ch=1)
setAttr('%s_lowArm_IK.rotateY'%ArmSide,0)
YJ_Creat_IK('%s_upArm_IK'%ArmSide,'%s_hand_IK'%ArmSide,'ikRPsolver')
YJ_Creat_Ctrl(4,'%s_hand_IK_anim'%ArmSide)
YJ_MoveToTargetWd('%s_hand_IK'%ArmSide,'%s_hand_IK_anim'%ArmSide)
YJRigZeroGrp(['%s_hand_IK_anim'%ArmSide])
CreatLocToTarget('%s_ArmPv_loc'%ArmSide,'%s_lowArm_IK'%ArmSide)
YJ_RotateToTargetWd('%s_ArmPv_loc'%ArmSide,'%s_lowArm_IK'%ArmSide)
poleVectorConstraint( '%s_ArmPv_loc'%ArmSide, '%s_upArm_IK_IKHandle'%ArmSide)
parent('%s_upArm_IK_IKHandle'%ArmSide,'%s_hand_IK_anim'%ArmSide)
CreatLocToTarget('L_upArm_CV_Loc','L_upArm_Bone')
CreatLocToTarget('L_lowArm_CV_Loc','L_lowArm_Bone')
CreatLocToTarget('L_hand_CV_Loc','L_hand_Bone')
CreatStretchCV('L_upArm_CV_Loc' ,'L_lowArm_CV_Loc' ,'L_upArm_CV')
CreatStretchCV('L_lowArm_CV_Loc' ,'L_hand_CV_Loc' ,'L_lowArm_CV')
CreatStretchCV('L_upArm_CV_Loc' ,'L_hand_CV_Loc' ,'L_Arm_CV')
def YJ_Creat_Stretch(IK_Start_Joint,IK_Sec_Joint,IK_End_Joint,EndAnim,PvAnim):
IK_Start_Loc=IK_Start_Joint.replace('IK','CV_Loc')
IK_Sec_Loc=IK_Sec_Joint.replace('IK','CV_Loc')
IK_End_Loc=IK_End_Joint.replace('IK','CV_Loc')
IK_Start_CV=IK_Start_Joint.replace('IK','CV')
IK_Sec_CV=IK_Sec_Joint.replace('IK','CV')
IK_End_CV=IK_End_Joint.replace('IK','CV')
CreatLocToTarget(IK_Start_Loc,IK_Start_Joint)
CreatLocToTarget(IK_Sec_Loc,IK_Sec_Joint)
CreatLocToTarget(IK_End_Loc,IK_End_Joint)
CreatStretchCV(IK_Start_Loc ,IK_Sec_Loc ,IK_Start_CV)
CreatStretchCV(IK_Sec_Loc ,IK_End_Loc ,IK_Sec_CV)
CreatStretchCV(IK_Start_Loc ,IK_End_Loc ,IK_End_CV)
addAttr( IK_Sec_Loc,longName='Lock', attributeType='double',min=0,max=1,dv=1,k=1)
IK_Grp=IK_Start_Joint+'_Grp'
Dis_Grp=IK_Start_Joint+'_Dis_Grp'
group( em=True, name=IK_Grp)
YJ_MoveToTargetWd(IK_Start_Joint,IK_Grp)
group( em=True, name=Dis_Grp)
YJ_MoveToTargetWd(IK_Start_Joint,Dis_Grp)
parent(IK_Start_Loc,IK_Grp)
parent(IK_Start_Joint,IK_Grp)
parent(IK_Start_CV,Dis_Grp)
parent(IK_Sec_CV,Dis_Grp)
parent(IK_End_CV,Dis_Grp)
StartLen=getAttr('%s_Inf.arcLength'%IK_Start_CV)
SecLen=getAttr('%s_Inf.arcLength'%IK_Sec_CV)
AllLen=StartLen+SecLen
YJ_CreateMDNode(IK_Start_CV,StartLen,2)
YJ_CreateMDNode(IK_Sec_CV,SecLen,2)
YJ_CreateMDNode(IK_End_CV,AllLen,2)
YJ_CreateMDNode(IK_Start_CV,StartLen,1)
YJ_CreateMDNode(IK_Sec_CV,SecLen,1)
YJ_CreateMDNode(IK_End_CV,AllLen,1)
YJ_CreateConNode(IK_End_CV)
createNode( 'blendTwoAttr', n='%s_blendTwo'% IK_Start_CV)
createNode( 'blendTwoAttr', n='%s_blendTwo'%IK_Sec_CV )
connectAttr('%s_Inf.arcLength'%IK_Start_CV,'%s_Div.input1X'%IK_Start_CV,f=1)
connectAttr('%s_Inf.arcLength'%IK_Sec_CV,'%s_CV_Div.input1X'%IK_Sec_CV,f=1)
connectAttr('%s_Inf.arcLength'%IK_End_CV,'%s_Div.input1X'%IK_End_CV,f=1)
connectAttr('%s_Div.outputX'%IK_End_CV,'%s_Mul.input1X'%IK_End_CV,f=1)
connectAttr( '%s_Mul.outputX'%IK_End_CV,'%s_Con.firstTerm'%IK_End_CV,f=1)
connectAttr( '%s_Mul.outputX'%IK_End_CV,'%s_Con.colorIfTrueR'%IK_End_CV,f=1)
connectAttr( '%s_blendTwo.output'%IK_Start_CV,'%s_Mul.input1X'%IK_Start_CV,f=1)
connectAttr( '%s_blendTwo.output'%IK_Sec_CV,'%s_Mul.input1X'%IK_Sec_CV,f=1)
connectAttr( '%s_Con.outColorR'%IK_End_CV,'%s_blendTwo.input[0]'%IK_Sec_CV,f=1)
connectAttr( '%s_Div.outputX'%IK_Sec_CV,'%s_blendTwo.input[1]'%IK_Sec_CV,f=1)
connectAttr( '%s_Con.outColorR'%IK_End_CV,'%s_blendTwo.input[0]'%IK_Start_CV,f=1)
connectAttr( '%s_Div.outputX'%IK_Start_CV,'%s_blendTwo.input[1]'%IK_Start_CV,f=1)
connectAttr( '%s_Mul.outputX'%IK_Sec_CV,'%s.translateX'%IK_End_Joint,f=1)
connectAttr( '%s_Mul.outputX'%IK_Start_CV,'%s.translateX'%IK_Sec_Joint,f=1)
connectAttr( '%s_Loc.Lock'%IK_Sec_CV,'%s_blendTwo.attributesBlender'%IK_Start_CV,f=1)
connectAttr( '%s_Loc.Lock'%IK_Sec_CV,'%s_blendTwo.attributesBlender'%IK_Sec_CV,f=1)
connectAttr('%s.Stretch'%EndAnim,'%s_Mul.input2X'%IK_End_CV,f=1)
connectAttr('%s.Lock'%PvAnim,'%s.Lock'%IK_Sec_Loc,f=1)
shadingNode('condition',asUtility=1,n='L_Arm_Con')
setAttr('L_Arm_Con.operation',2)
setAttr('L_Arm_Con.secondTerm',1)
connectAttr('L_Arm_CV_Div.outputX','L_Arm_Con.colorIfTrueR',f=1)
connectAttr('L_Arm_Stretch_Mul.outputX','L_Arm_Con.firstTerm',f=1)
def YJ_CreateMDNode(IK_CV,CVLen,op):
if op == 1:
MD_Name=IK_CV+'_Mul'
else:
MD_Name=IK_CV+'_Div'
shadingNode('multiplyDivide',asUtility=1,n=MD_Name )
setAttr('%s.operation'%MD_Name,op)
setAttr('%s.input2X'%MD_Name,CVLen)
def YJ_CreateConNode(ConName):
ConNameNew=ConName+'_Con'
shadingNode('condition',asUtility=1,n=ConNameNew)
setAttr('%s.operation'%ConNameNew,2)
setAttr('%s.secondTerm'%ConNameNew,1)
addAttr( 'L_hand_IK_anim',longName='Stretch', attributeType='double',min=0,max=1,dv=1,k=1)
addAttr( 'L_ArmPv_loc',longName='Lock', attributeType='double',min=0,max=1,dv=1,k=1)
group( em=True, name='L_upArm_IK_Grp')
YJ_MoveToTargetWd('L_upArm_IK','L_upArm_IK_Grp')
parent('L_upArm_CV_Loc','L_upArm_IK_Grp')
parent('L_upArm_IK','L_upArm_IK_Grp')
upArmLen=getAttr('L_upArm_CV_Inf.arcLength')
lowArmLen=getAttr('L_lowArm_CV_Inf.arcLength')
ArmLen=upArmLen+lowArmLen
parent('L_lowArm_CV_Loc','L_ArmPv_loc')
parent('L_hand_CV_Loc','L_hand_IK_anim')
shadingNode('multiplyDivide',asUtility=1,n='L_upArm_CV_Div')
setAttr('L_upArm_CV_Div.operation',2)
setAttr('L_upArm_CV_Div.input2X',upArmLen)
connectAttr('L_upArm_CV_Inf.arcLength','L_upArm_CV_Div.input1X',f=1)
shadingNode('multiplyDivide',asUtility=1,n='L_lowArm_CV_Div')
setAttr('L_lowArm_CV_Div.operation',2)
setAttr('L_lowArm_CV_Div.input2X',lowArmLen)
connectAttr('L_lowArm_CV_Inf.arcLength','L_lowArm_CV_Div.input1X',f=1)
shadingNode('multiplyDivide',asUtility=1,n='L_Arm_CV_Div')
setAttr('L_Arm_CV_Div.operation',2)
setAttr('L_Arm_CV_Div.input2X',ArmLen)
connectAttr('L_Arm_CV_Inf.arcLength','L_Arm_CV_Div.input1X',f=1)
shadingNode('condition',asUtility=1,n='L_Arm_Con')
setAttr('L_Arm_Con.operation',2)
setAttr('L_Arm_Con.secondTerm',1)
connectAttr('L_Arm_CV_Div.outputX','L_Arm_Con.colorIfTrueR',f=1)
shadingNode('multiplyDivide',asUtility=1,n='L_Arm_upArm_CV_Mul')
setAttr('L_Arm_upArm_CV_Mul.input2X',upArmLen)
connectAttr('L_Arm_Con.outColorR','L_Arm_upArm_CV_Mul.input1X',f=1)
connectAttr('L_Arm_upArm_CV_Mul.outputX','L_lowArm_IK.tx',f=1)
shadingNode('multiplyDivide',asUtility=1,n='L_Arm_lowArm_CV_Mul')
setAttr('L_Arm_lowArm_CV_Mul.input2X',lowArmLen)
connectAttr('L_Arm_Con.outColorR','L_Arm_lowArm_CV_Mul.input1X',f=1)
connectAttr('L_Arm_lowArm_CV_Mul.outputX','L_hand_IK.tx',f=1)
shadingNode('multiplyDivide',asUtility=1,n='L_Arm_Stretch_Mul')
connectAttr('L_Arm_CV_Div.outputX','L_Arm_Stretch_Mul.input1X',f=1)
connectAttr('L_hand_IK_anim.Stretch','L_Arm_Stretch_Mul.input2X',f=1)
connectAttr('L_Arm_Stretch_Mul.outputX','L_Arm_Con.firstTerm',f=1)
group( 'L_upArm_CV', 'L_lowArm_CV','L_Arm_CV', n='L_Arm_Dis_CV_Grp' )
addAttr( 'L_hand_IK_anim',longName='Stretch', attributeType='double',min=0,max=1,dv=1,k=1)