#NEWLINE# def doSetup( baseName , numberTwistJoints , knee , hip , pelvis , hipAimAxis , hipFrontAxis , pelvisAimAxis , pelvisFrontAxis ) : #NEWLINE# #INDENT# 'This function creates the new twist joints and returns a list of their names.' #NEWLINE# try : #NEWLINE# #INDENT# utils . dg . validateNodeName ( baseName ) #NEWLINE# utils . dg . verifyNode ( knee ) #NEWLINE# utils . dg . verifyNode ( hip ) #NEWLINE# utils . dg . verifyNode ( pelvis ) #NEWLINE# kneeTranslate = cmds . getAttr ( ( '%s.translate' % knee ) ) [ 0 ] #NEWLINE# bodySide = cmds . getAttr ( ( '%s.side' % hip ) ) #NEWLINE# rotateOrder = cmds . getAttr ( ( '%s.rotateOrder' % hip ) ) #NEWLINE# twistJoints = [ ] #NEWLINE# for i in range ( numberTwistJoints ) : #NEWLINE# #INDENT# cmds . select ( cl = True ) #NEWLINE# newJoint = cmds . joint ( name = ( '%s%s' % ( baseName , ( i + 1 ) ) ) ) #NEWLINE# if ( i == 0 ) : #NEWLINE# #INDENT# newJoint = cmds . parent ( newJoint , hip ) [ 0 ] #NEWLINE# jointRadius = 1.0 #NEWLINE# jointOrient = [ ] #NEWLINE# if cmds . objectType ( hip , isType = 'joint' ) : #NEWLINE# #INDENT# jointRadius = ( cmds . getAttr ( ( '%s.radius' % hip ) ) * 0.5 ) #NEWLINE# #UNINDENT# cmds . setAttr ( ( '%s.radius' % newJoint ) , jointRadius ) #NEWLINE# cmds . setAttr ( ( '%s.jointOrient' % newJoint ) , 0 , 0 , 0 ) #NEWLINE# cmds . setAttr ( ( '%s.translate' % newJoint ) , 0 , 0 , 0 ) #NEWLINE# cmds . am_hipConstraint ( newJoint , pelvisObject = pelvis , hipObject = hip , ha = hipAimAxis , hf = hipFrontAxis , pa = pelvisAimAxis , pf = pelvisFrontAxis ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# newJoint = cmds . parent ( newJoint , hip ) [ 0 ] #NEWLINE# cmds . setAttr ( ( '%s.radius' % newJoint ) , jointRadius ) #NEWLINE# cmds . setAttr ( ( '%s.jointOrient' % newJoint ) , 0 , 0 , 0 ) #NEWLINE# pct = ( float ( i ) / float ( numberTwistJoints ) ) #NEWLINE# cmds . setAttr ( ( '%s.translate' % newJoint ) , ( kneeTranslate [ 0 ] * pct ) , ( kneeTranslate [ 1 ] * pct ) , ( kneeTranslate [ 2 ] * pct ) ) #NEWLINE# orientConstraint = cmds . orientConstraint ( [ twistJoints [ 0 ] , hip , newJoint ] ) #NEWLINE# targetWeights = cmds . orientConstraint ( q = True , weightAliasList = True ) #NEWLINE# cmds . setAttr ( ( '%s.%s' % ( orientConstraint [ 0 ] , targetWeights [ 0 ] ) ) , ( numberTwistJoints - i ) ) #NEWLINE# cmds . setAttr ( ( '%s.%s' % ( orientConstraint [ 0 ] , targetWeights [ 1 ] ) ) , i ) #NEWLINE# cmds . setAttr ( ( '%s.interpType' % orientConstraint [ 0 ] ) , 1 ) #NEWLINE# #UNINDENT# cmds . setAttr ( ( '%s.side' % newJoint ) , bodySide ) #NEWLINE# cmds . setAttr ( ( '%s.type' % newJoint ) , 18 ) #NEWLINE# cmds . setAttr ( ( '%s.otherType' % newJoint ) , ( 'Hip Twist %s' % ( i + 1 ) ) , type = 'string' ) #NEWLINE# cmds . setAttr ( ( '%s.rotateOrder' % newJoint ) , rotateOrder ) #NEWLINE# twistJoints . append ( newJoint ) #NEWLINE# #UNINDENT# return twistJoints #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# raise