Пример #1
0
    def rig_createFkChain(self, topNode=None):
        ''' Create Fk controls and attributes and SH joint chain '''
        # Get the root locators
        rootLocs = pm.listRelatives('HairRig_MainCnt', children=True)[1:]

        # Per chain
        index = 0
        for chainName, numJnts in zip(self.chainNames, self.chainNumJnts):
            # Chain grp
            chainGrp = pm.group(n=chainName + '_hr_fk_grp',
                                parent=topNode,
                                em=True)
            pm.delete(pm.parentConstraint(rootLocs[index], chainGrp, mo=0))

            # Get locator names
            locNames = [
                '%s_loc%s' % (chainName, num) for num in range(int(numJnts))
                if num != 0
            ]
            locNames.insert(0, '%s_rootLoc' % chainName)

            # Get locator positions
            positions = []
            for loc in locNames:
                positions.append(pm.xform(loc, q=1, ws=1, t=1))

            # Draw fk joint chain
            fkJnts = []
            pm.select(chainGrp, replace=True)
            for i in range(len(positions)):
                fkJnts.append(
                    pm.joint(name=chainName + '_hr_fkJnt_%s' % i,
                             p=positions[i]))

            index = index + 1

            # Create Fk controls and attributes
            label = chainName
            control = 'HairRig_MainCnt'
            fkControl = pm.circle(nr=(0, 0, 1), c=(0, 0, 0), ch=False)[0]

            aim = 'Z'
            twist = 'Y'
            up = 'X'

            # Create main attributes on control
            pm.select(control, r=True)
            attList = pm.attributeInfo(control, all=True)

            if (label not in attList):
                try:
                    pm.addAttr(longName=label, k=True)
                    pm.setAttr(control + '.' + label, lock=True)
                except:
                    pass  #Attribute already exists

            #Get data for current limb
            startJnt = pm.listRelatives(chainGrp, children=True)[0]
            pm.select(pm.listRelatives(chainGrp, children=True)[0], hi=True)
            endJnt = pm.ls(sl=1)[-1]

            #Get full chain
            chain = []

            #Get the hierarchy of startJnt, then store it until endJnt is found
            try:
                pm.select(startJnt, r=True, hi=True)
                sel = pm.ls(sl=True, fl=True, type='joint')
                tempChain = sel

                for each in tempChain:
                    if each == endJnt:
                        chain.append(each)
                        break
                    else:
                        chain.append(each)
            except:
                pass

            #Store parent of chain
            parent = pm.listRelatives(chain[0], parent=True)

            #Unparent joints
            for each in chain:
                try:
                    pm.parent(each, w=True)
                except:
                    pass

            #Create duplicate joints above orig joints, then store duplicate joint names
            dupJoints = []
            for joint in chain:
                offName = joint + '_off'
                jnt = pm.duplicate(joint, rr=True, po=True, n=offName)
                dupJoints.append(jnt)

            #Rebuild heirarchy
            x = 0
            while x < len(chain):
                pm.parent(chain[x], dupJoints[x])
                if x != 0:
                    pm.parent(dupJoints[x], chain[x - 1])
                x = x + 1

            # Add dynamic switch attribute
            pm.addAttr(control,
                       longName=chainName + '_dynamic',
                       k=True,
                       min=0,
                       max=1)

            #Adding Curl atts on controller
            x = 0
            while x < len(chain):
                pm.addAttr(control,
                           longName=chainName + '_curl_' + str(x + 1),
                           k=True)
                x = x + 1

            #Adding spread atts on controller
            x = 0
            while x < len(chain):
                pm.addAttr(control,
                           longName=chainName + '_spread_' + str(x + 1),
                           k=True)
                x = x + 1

            #Twist
            pm.addAttr(control, longName=chainName + '_Twist', k=True)

            #Connect attributes to dupJoints rotate's ( aim = curl, up = spread )
            x = 0
            pm.connectAttr(control + '.' + chainName + '_Twist',
                           str(dupJoints[x][0]) + '.rotate' + twist)
            while x < len(chain):
                pm.connectAttr(
                    control + '.' + chainName + '_curl_' + str(x + 1),
                    str(dupJoints[x][0]) + '.rotate' + aim)
                pm.connectAttr(
                    control + '.' + chainName + '_spread_' + str(x + 1),
                    str(dupJoints[x][0]) + '.rotate' + up)
                x = x + 1

            #Create fk controllers on joints
            #Duplicate FK control, parent it to chain joints, delete left over transform node
            for each in chain:
                #Duplicate control
                tempCnt = pm.duplicate(fkControl)
                #Select the shape
                tempShp = pm.pickWalk(tempCnt, direction='down')
                pm.parent(tempShp, each, r=True, s=True)
                pm.delete(tempCnt)

            pm.parent(dupJoints[0], chainGrp)
            pm.delete(fkControl)

            pm.parentConstraint('HairRig_MainCnt', chainGrp, mo=True)
Пример #2
0
    def rig_createFkChain(self, topNode=None):
        ''' Create Fk controls and attributes and SH joint chain '''
        # Get the root locators
        rootLocs = pm.listRelatives('HairRig_MainCnt',children=True)[1:]

        # Per chain
        index = 0
        for chainName, numJnts in zip(self.chainNames, self.chainNumJnts):
            # Chain grp
            chainGrp = pm.group(n=chainName+'_hr_fk_grp', parent=topNode, em=True)
            pm.delete(pm.parentConstraint(rootLocs[index],chainGrp,mo=0))

            # Get locator names
            locNames = ['%s_loc%s'%(chainName,num) for num in range(int(numJnts)) if num != 0]
            locNames.insert(0,'%s_rootLoc'%chainName)

            # Get locator positions
            positions = []
            for loc in locNames:
                positions.append(pm.xform(loc,q=1,ws=1,t=1))

            # Draw fk joint chain
            fkJnts = []
            pm.select(chainGrp,replace=True)
            for i in range(len(positions)):
                fkJnts.append(pm.joint(name=chainName+'_hr_fkJnt_%s'%i, p=positions[i])) 
                
            index = index + 1

            # Create Fk controls and attributes
            label = chainName
            control = 'HairRig_MainCnt'
            fkControl = pm.circle( nr=(0, 0, 1), c=(0, 0, 0), ch=False )[0]

            aim = 'Z'
            twist = 'Y'
            up = 'X'

            # Create main attributes on control
            pm.select(control,r=True)
            attList = pm.attributeInfo(control,all=True)

            if(label not in attList):
                try:
                    pm.addAttr(longName=label,k=True)
                    pm.setAttr(control + '.' + label, lock=True)
                except:
                    pass #Attribute already exists

            #Get data for current limb
            startJnt = pm.listRelatives(chainGrp,children=True)[0]
            pm.select(pm.listRelatives(chainGrp,children=True)[0], hi=True)
            endJnt = pm.ls(sl=1)[-1]

            #Get full chain
            chain = []

            #Get the hierarchy of startJnt, then store it until endJnt is found
            try:
                pm.select(startJnt,r=True,hi=True)
                sel = pm.ls(sl=True,fl=True,type='joint')
                tempChain = sel

                for each in tempChain:
                    if each == endJnt:
                        chain.append(each)
                        break
                    else:
                        chain.append(each)
            except:
                pass

            #Store parent of chain
            parent = pm.listRelatives( chain[0], parent=True)

            #Unparent joints
            for each in chain:
                try:
                    pm.parent(each,w=True)
                except:
                    pass

            #Create duplicate joints above orig joints, then store duplicate joint names
            dupJoints = []
            for joint in chain:
                offName = joint + '_off'
                jnt = pm.duplicate(joint,rr=True,po=True,n=offName)
                dupJoints.append(jnt)

            #Rebuild heirarchy
            x = 0
            while x < len(chain):
                pm.parent(chain[x],dupJoints[x])
                if x != 0:
                    pm.parent(dupJoints[x],chain[x-1])
                x = x + 1

            # Add dynamic switch attribute
            pm.addAttr( control, longName=chainName + '_dynamic', k=True, min=0, max=1 )

            #Adding Curl atts on controller
            x= 0 
            while x < len(chain):
                pm.addAttr(control, longName=chainName + '_curl_' + str(x+1),k=True)
                x = x + 1

            #Adding spread atts on controller
            x= 0 
            while x < len(chain):
                pm.addAttr(control, longName=chainName + '_spread_' + str(x+1),k=True)
                x = x + 1

            #Twist
            pm.addAttr(control, longName=chainName + '_Twist',k=True)

            #Connect attributes to dupJoints rotate's ( aim = curl, up = spread )
            x = 0
            pm.connectAttr( control + '.' + chainName + '_Twist' , str(dupJoints[x][0]) + '.rotate' + twist ) 
            while x < len(chain):
                pm.connectAttr( control + '.' + chainName + '_curl_' + str(x+1) , str(dupJoints[x][0]) + '.rotate' + aim )
                pm.connectAttr( control + '.' + chainName + '_spread_' + str(x+1), str(dupJoints[x][0]) + '.rotate' + up )
                x = x + 1

            #Create fk controllers on joints
            #Duplicate FK control, parent it to chain joints, delete left over transform node
            for each in chain:
                #Duplicate control
                tempCnt = pm.duplicate(fkControl)
                #Select the shape
                tempShp = pm.pickWalk(tempCnt,direction='down')
                pm.parent(tempShp,each,r=True,s=True)
                pm.delete(tempCnt)
            
            pm.parent( dupJoints[0], chainGrp )
            pm.delete( fkControl )
            
            pm.parentConstraint( 'HairRig_MainCnt', chainGrp, mo=True )
Пример #3
0
def build(side=None,
          label='Fingers',
          control=None,
          parentJnt=None,
          curl='Z',
          twist='X',
          spread='Y',
          fkNormal=(1.0, 0.0, 0.0),
          radius=0.3):

    pymelLogger.debug('Starting: build()...')

    if side == None: raise Exception('Make sure side: %s is valid ' % side)
    if side == Names.prefixes['left']:
        fingerJnts = Names.joints_leftFingers_list
    elif side == Names.prefixes['right']:
        fingerJnts = Names.joints_rightFingers_list
    else:
        raise Exception('Make sure side: %s is valid ' % side)

    # Is the last joint of the chain going to be skinned ? hasEndJnt = 0
    # or last joint should not be considered ? hasEndJnt = 1
    hasEndJnt = 1  # hard coding it, by default last joint will not be considered

    rList = createJnts(
        side, fingerJnts,
        hasEndJnt)  # [ startJnts, endJnts, attNames, newJnts, originalJnts ]
    startJnts = rList[0]
    endJnts = rList[1]
    attNames = rList[2]
    newJnts = rList[3]
    originalJnts = rList[4]

    # Create main attributes on control
    pm.select(control, r=True)
    attList = pm.attributeInfo(control, all=True)

    if (label not in attList):
        try:
            pm.addAttr(longName=label, k=True)
            pm.setAttr(control + '.' + label, lock=True)
        except:
            pass  #Attribute already exists @ todo - Catch specific exemption

    # Create controller vis switch
    pm.addAttr(longName='Control_Vis', k=True, min=0, max=1, dv=1)

    # Create spread all
    pm.addAttr(longName='spread_all', k=True, min=-10.0, max=10.0)

    # Create tenson all
    pm.addAttr(longName='tension_all', k=True, min=0.0, max=10.0)

    # Create tenson all
    pm.addAttr(longName='curl_all', k=True)

    chainParent = ''

    offsetGrpsLists = []

    ########################################################
    ########################################################
    ########################################################
    # spread hard coded calculation #
    jntLen = len(startJnts)
    startValue = -50
    endValue = 50
    range = -(startValue) + endValue
    increment = range / jntLen
    startV = startValue
    endV = endValue

    spreadList = []
    if jntLen % 2 == 0:
        centerIndex = jntLen / 2
        index = 1
        while index < jntLen + 1:
            if index < centerIndex:
                spreadList.append([startV, endV])
                startV = startV + increment
                endV = endV - increment
            if index > centerIndex:
                spreadList.append([startV, endV])
                startV = startV + increment
                endV = endV - increment
            index = index + 1
    else:
        centerIndex = (jntLen + 1) / 2
        index = 1
        while index < jntLen + 1:
            if index < centerIndex:
                spreadList.append([startV, endV])
                startV = startV + increment
                endV = endV - increment
            if index == centerIndex:
                spreadList.append([0, 0])
                startV = 0 + increment
                endV = 0 - increment
            if index > centerIndex:
                spreadList.append([startV, endV])
                startV = startV + increment
                endV = endV - increment
            index = index + 1
    ########################################################
    ########################################################
    ########################################################

    print 'spread list ', spreadList
    # Iterate the attNames, startJnts, endJnts at the same time.
    for (name, startJnt, endJnt, spr) in zip(attNames, startJnts, endJnts,
                                             spreadList):
        #Get full chain
        chain = []

        #Get the hierarchy of startJnt, then store it until endJnt is found
        try:
            pm.select(startJnt, r=True, hi=True)
            sel = pm.ls(sl=True, fl=True, type='joint')
            tempChain = sel

            for each in tempChain:
                if each == endJnt:
                    chain.append(each)
                    break
                else:
                    chain.append(each)
        except:
            pass

        #Store parent of chain if it has one
        try:
            chainParent = pm.listRelatives(chain[0], parent=True)
        except:
            pass

        offsetGrps = [
            '_crv_jnt', '_cntrl_jnt', '_tension_jnt', '_curl_jnt', '_all_jnt',
            'offsetGrp'
        ]
        offsetGrpList = []

        for joint in chain:
            # create offset groups for finger controls
            ctrlName = joint.replace('_' + Names.suffixes['fk'],
                                     '_' + Names.suffixes['control'])
            ctrlPos = pm.xform(joint, query=True, translation=True, ws=1)
            ctrlRot = pm.xform(joint, query=True, ro=True, ws=1)

            offsetGrp = Control.create(name=ctrlName,
                                       offsets=len(offsetGrps),
                                       shape='circle_01',
                                       size=radius,
                                       color=getSideColor(side),
                                       pos=ctrlPos,
                                       parent=None,
                                       rot=ctrlRot,
                                       typ='body')

            offsetGrpList.append(offsetGrp)

            # parent contraint ctrl to fk jnt
            pm.parentConstraint(offsetGrp.listRelatives(ad=1)[0].getParent(),
                                joint,
                                mo=True)

            # set Control_Vis attr!!!

            pm.connectAttr(
                control + '.' + 'Control_Vis',
                offsetGrp.listRelatives(ad=1)[0].getParent() + '.visibility')

        ### hard coding it for now! until better solution and more time
        cntrlJoints = []
        curlJoints = []
        tensionJoints = []
        allJoints = []

        for off in offsetGrpList:
            for elem in off.listRelatives(ad=1):
                if '_offsetE' in str(elem): cntrlJoints.append(elem)
                elif '_offsetB' in str(elem): allJoints.append(elem)
                elif '_offsetD' in str(elem): curlJoints.append(elem)
                elif '_offsetC' in str(elem): tensionJoints.append(elem)

        print cntrlJoints
        print curlJoints
        print tensionJoints
        print allJoints

        offsetGrpList.reverse()
        index = 0
        for grp in offsetGrpList:
            if index + 1 == len(offsetGrpList): break
            grp.setParent(offsetGrpList[index +
                                        1].listRelatives(ad=1)[0].getParent())
            index = index + 1

        offsetGrpList.reverse()
        offsetGrpsLists.append(offsetGrpList)

        # Adding Curl attrs on controller
        x = 0
        while x < len(chain):
            pm.addAttr(control, longName=name + '_curl_' + str(x + 1), k=True)
            x = x + 1

        # Adding spread attr on controller
        pm.addAttr(control, longName=name + '_spread', k=True)

        # Twist
        pm.addAttr(control, longName=name + '_twist', k=True)

        # Tension
        pm.addAttr(control, longName=name + '_tension', k=True)

        # Connect attributes to cntrlJoints rotate's ( aim = curl, up = spread )
        x = 0
        pm.connectAttr(control + '.' + name + '_twist',
                       str(cntrlJoints[0]) + '.rotate' + twist)
        pm.connectAttr(control + '.' + name + '_spread',
                       str(cntrlJoints[0]) + '.rotate' + spread)

        while x < len(chain):
            pm.connectAttr(control + '.' + name + '_curl_' + str(x + 1),
                           str(cntrlJoints[x]) + '.rotate' + curl)
            x = x + 1

        #SDK attributes to curl All
        x = 0
        while x < len(curlJoints):
            pm.connectAttr(control + '.curl_all',
                           str(curlJoints[x]) + '.rotate' + curl)
            x = x + 1

        #SDK attributes to tensionJoints rotate's ( aim = curl )
        x = 0
        while x < len(tensionJoints):
            # Root joint curls back
            if x == 0:
                pm.setDrivenKeyframe(tensionJoints[x],
                                     cd=control + '.' + name + '_tension',
                                     at="rotate%s" % curl,
                                     dv=0,
                                     v=0)
                pm.setDrivenKeyframe(tensionJoints[x],
                                     cd=control + '.' + name + '_tension',
                                     at="rotate%s" % curl,
                                     dv=10,
                                     v=60)
                x += 1
                continue

            # All oher joints curl forword
            pm.setDrivenKeyframe(tensionJoints[x],
                                 cd=control + '.' + name + '_tension',
                                 at="rotate%s" % curl,
                                 dv=0,
                                 v=0)
            pm.setDrivenKeyframe(tensionJoints[x],
                                 cd=control + '.' + name + '_tension',
                                 at="rotate%s" % curl,
                                 dv=10,
                                 v=-50)

            x = x + 1

        # SDK All tension
        x = 0
        while x < len(allJoints):
            # all_tension
            if x == 0:
                pm.setDrivenKeyframe(allJoints[x],
                                     cd=control + '.tension_all',
                                     at="rotate%s" % curl,
                                     dv=0,
                                     v=0)
                pm.setDrivenKeyframe(allJoints[x],
                                     cd=control + '.tension_all',
                                     at="rotate%s" % curl,
                                     dv=10,
                                     v=60)
                x += 1
                continue

            # All other joints curl forward
            pm.setDrivenKeyframe(allJoints[x],
                                 cd=control + '.tension_all',
                                 at="rotate%s" % curl,
                                 dv=0,
                                 v=0)
            pm.setDrivenKeyframe(allJoints[x],
                                 cd=control + '.tension_all',
                                 at="rotate%s" % curl,
                                 dv=10,
                                 v=-50)
            x += 1

        # SDK All spread
        #pm.connectAttr( control + '.spread_all', str(allJoints[0]) + '.rotate' + spread )

        x = 0
        while x < len(allJoints):
            # spread_all
            if x == 0:
                pm.setDrivenKeyframe(allJoints[x],
                                     cd=control + '.spread_all',
                                     at="rotate%s" % spread,
                                     dv=-10,
                                     v=spr[0])
                pm.setDrivenKeyframe(allJoints[x],
                                     cd=control + '.spread_all',
                                     at="rotate%s" % spread,
                                     dv=10,
                                     v=spr[1])
                x += 1
                continue
            """
            # All other joints curl forward
            pm.setDrivenKeyframe( allJoints[x], 
                            cd=control + '.spread_all',
                            at= "rotate%s"%spread,
                            dv = 0,
                            v = 0 )
            pm.setDrivenKeyframe( allJoints[x], 
                            cd=control + '.spread_all',
                            at= "rotate%s"%spread,
                            dv = 10,
                            v = 50 )
            """
            x += 1

        pm.select(clear=True)

    _connectToSH(newJnts, originalJnts)

    # connecting to hand jnt if passed
    if parentJnt:
        _connectToHandJnt(parentJnt, newJnts, offsetGrpsLists)

    pymelLogger.debug('End: build()...')
Пример #4
0
def build( side=None, label='Fingers',control=None, parentJnt=None,
          curl='Z',twist='X',spread='Y',
          fkNormal=(1.0, 0.0, 0.0), radius=0.3):


    pymelLogger.debug('Starting: build()...') 
    
    if side == None: raise Exception('Make sure side: %s is valid '%side) 
    if side == Names.prefixes['left']: fingerJnts = Names.joints_leftFingers_list
    elif side == Names.prefixes['right']: fingerJnts = Names.joints_rightFingers_list
    else: raise Exception('Make sure side: %s is valid '%side)
    

    # Is the last joint of the chain going to be skinned ? hasEndJnt = 0
    # or last joint should not be considered ? hasEndJnt = 1
    hasEndJnt = 1 # hard coding it, by default last joint will not be considered
    
    rList = createJnts( side, fingerJnts, hasEndJnt ) # [ startJnts, endJnts, attNames, newJnts, originalJnts ]
    startJnts = rList[0]
    endJnts = rList[1]
    attNames = rList[2]
    newJnts = rList[3]
    originalJnts = rList[4]

    # Create main attributes on control
    pm.select(control,r=True)
    attList = pm.attributeInfo(control,all=True)

    if(label not in attList):
        try:
            pm.addAttr(longName=label,k=True)
            pm.setAttr(control + '.' + label, lock=True)
        except:
            pass #Attribute already exists @ todo - Catch specific exemption
        
    # Create controller vis switch
    pm.addAttr(longName='Control_Vis',k=True, min=0, max=1,dv=1)
    
    # Create spread all
    pm.addAttr(longName='spread_all',k=True, min=-10.0, max=10.0)
    
    # Create tenson all
    pm.addAttr(longName='tension_all',k=True, min=0.0, max=10.0)
    
    # Create tenson all
    pm.addAttr(longName='curl_all',k=True)

    chainParent = ''
    
    offsetGrpsLists = []
    
    ######################################################## 
    ######################################################## 
    ######################################################## 
    # spread hard coded calculation #
    jntLen = len(startJnts)
    startValue=-50
    endValue=50
    range = -(startValue) + endValue
    increment = range / jntLen
    startV = startValue
    endV = endValue
    
    spreadList=[]
    if jntLen%2==0:
        centerIndex = jntLen/2
        index=1
        while index < jntLen+1:
            if index < centerIndex:
                spreadList.append( [startV,endV] )
                startV = startV + increment
                endV = endV - increment
            if index > centerIndex:
                spreadList.append( [startV,endV] )
                startV = startV + increment
                endV = endV - increment
            index = index + 1
    else:
        centerIndex = (jntLen+1)/2
        index=1
        while index < jntLen+1:
            if index < centerIndex:
                spreadList.append( [startV,endV] )
                startV = startV + increment
                endV = endV - increment
            if index == centerIndex:
                spreadList.append([0,0])
                startV = 0 + increment
                endV = 0 - increment
            if index > centerIndex:
                spreadList.append( [startV,endV] )
                startV = startV + increment
                endV = endV - increment
            index = index + 1
    ########################################################           
    ######################################################## 
    ########################################################  
     
     
    print 'spread list ', spreadList
    # Iterate the attNames, startJnts, endJnts at the same time.
    for (name,startJnt,endJnt,spr) in zip(attNames,startJnts,endJnts,spreadList):
        #Get full chain
        chain = []
    
        #Get the hierarchy of startJnt, then store it until endJnt is found
        try:
            pm.select(startJnt,r=True,hi=True)
            sel = pm.ls(sl=True,fl=True,type='joint')
            tempChain = sel
    
            for each in tempChain:
                if each == endJnt:
                    chain.append(each)
                    break
                else:
                    chain.append(each)
        except:
            pass
    
        #Store parent of chain if it has one
        try:
            chainParent = pm.listRelatives(chain[0],parent=True)
        except:
            pass
 
        
            
        offsetGrps = ['_crv_jnt','_cntrl_jnt','_tension_jnt','_curl_jnt','_all_jnt','offsetGrp']
        offsetGrpList = []
        
        for joint in chain:
            # create offset groups for finger controls
            ctrlName = joint.replace( '_' + Names.suffixes['fk'], '_' + Names.suffixes['control'] )
            ctrlPos = pm.xform(joint, query = True, translation = True, ws=1)
            ctrlRot = pm.xform(joint, query = True, ro = True, ws=1)
           
            offsetGrp = Control.create( name=ctrlName, offsets=len(offsetGrps), shape='circle_01', 
                            size=radius, color=getSideColor(side), 
                            pos=ctrlPos, parent=None,rot=ctrlRot, typ='body' ) 
            
            offsetGrpList.append(offsetGrp)
            
            # parent contraint ctrl to fk jnt
            pm.parentConstraint( offsetGrp.listRelatives(ad=1)[0].getParent(), joint, mo=True )
            
            
            # set Control_Vis attr!!!
            
            pm.connectAttr(control +'.'+ 'Control_Vis', offsetGrp.listRelatives(ad=1)[0].getParent() + '.visibility') 
            
 
        
        ### hard coding it for now! until better solution and more time
        cntrlJoints = [] 
        curlJoints = [] 
        tensionJoints = [] 
        allJoints = [] 
        
       
        for off in offsetGrpList:   
            for elem in off.listRelatives(ad=1):
                if '_offsetE' in str(elem): cntrlJoints.append(elem)
                elif '_offsetB' in str(elem): allJoints.append(elem)
                elif '_offsetD' in str(elem): curlJoints.append(elem)
                elif '_offsetC' in str(elem): tensionJoints.append(elem)
                
                
                
                

        print cntrlJoints
        print curlJoints
        print tensionJoints
        print allJoints

        
        offsetGrpList.reverse()
        index = 0
        for grp in offsetGrpList:
            if index+1 == len(offsetGrpList): break
            grp.setParent(offsetGrpList[index+1].listRelatives(ad=1)[0].getParent())
            index = index + 1
            
        offsetGrpList.reverse() 
        offsetGrpsLists.append( offsetGrpList )
        
       
         
         
            
        # Adding Curl attrs on controller
        x= 0 
        while x < len(chain):
            pm.addAttr(control, longName=name + '_curl_' + str(x+1),k=True)
            x = x + 1
    
        # Adding spread attr on controller
        pm.addAttr(control, longName=name + '_spread',k=True)
    
        # Twist
        pm.addAttr(control, longName= name + '_twist',k=True)
        
        # Tension
        pm.addAttr(control, longName= name + '_tension',k=True)
    
        
        
        
        
        
        
        # Connect attributes to cntrlJoints rotate's ( aim = curl, up = spread )
        x = 0
        pm.connectAttr( control + '.' + name + '_twist' , str(cntrlJoints[0]) + '.rotate' + twist ) 
        pm.connectAttr( control + '.' + name + '_spread', str(cntrlJoints[0]) + '.rotate' + spread )
        
        while x < len(chain):
            pm.connectAttr( control + '.' + name + '_curl_' + str(x+1) , str(cntrlJoints[x]) + '.rotate' + curl )
            x = x + 1
            
        #SDK attributes to curl All
        x = 0
        while x < len(curlJoints):
            pm.connectAttr( control + '.curl_all', str(curlJoints[x]) + '.rotate' + curl )
            x = x + 1
 
        
        #SDK attributes to tensionJoints rotate's ( aim = curl )
        x = 0
        while x < len(tensionJoints):
            # Root joint curls back
            if x == 0:
                pm.setDrivenKeyframe( tensionJoints[x], 
                                cd=control + '.' + name + '_tension',
                                at= "rotate%s"%curl,
                                dv = 0,
                                v = 0 )
                pm.setDrivenKeyframe( tensionJoints[x], 
                                cd=control + '.' + name + '_tension',
                                at= "rotate%s"%curl,
                                dv = 10,
                                v = 60 )
                x += 1
                continue
            
            # All oher joints curl forword
            pm.setDrivenKeyframe( tensionJoints[x], 
                            cd=control + '.' + name + '_tension',
                            at= "rotate%s"%curl,
                            dv = 0,
                            v = 0 )
            pm.setDrivenKeyframe( tensionJoints[x], 
                            cd=control + '.' + name + '_tension',
                            at= "rotate%s"%curl,
                            dv = 10,
                            v = -50 )
                
            x = x + 1
        
        # SDK All tension
        x = 0
        while x < len(allJoints):
            # all_tension
            if x == 0:
                pm.setDrivenKeyframe( allJoints[x], 
                                cd=control + '.tension_all',
                                at= "rotate%s"%curl,
                                dv = 0,
                                v = 0 )
                pm.setDrivenKeyframe( allJoints[x], 
                                cd=control + '.tension_all',
                                at= "rotate%s"%curl,
                                dv = 10,
                                v = 60 )
                x += 1
                continue
            
            # All other joints curl forward
            pm.setDrivenKeyframe( allJoints[x], 
                            cd=control + '.tension_all',
                            at= "rotate%s"%curl,
                            dv = 0,
                            v = 0 )
            pm.setDrivenKeyframe( allJoints[x], 
                            cd=control + '.tension_all',
                            at= "rotate%s"%curl,
                            dv = 10,
                            v = -50 )
            x += 1
        
        
        
        # SDK All spread
        #pm.connectAttr( control + '.spread_all', str(allJoints[0]) + '.rotate' + spread )
        
        x = 0
        while x < len(allJoints):
            # spread_all
            if x == 0:
                pm.setDrivenKeyframe( allJoints[x], 
                                cd=control + '.spread_all',
                                at= "rotate%s"%spread,
                                dv = -10,
                                v = spr[0] )
                pm.setDrivenKeyframe( allJoints[x], 
                                cd=control + '.spread_all',
                                at= "rotate%s"%spread,
                                dv = 10,
                                v = spr[1] )
                x += 1
                continue
            """
            # All other joints curl forward
            pm.setDrivenKeyframe( allJoints[x], 
                            cd=control + '.spread_all',
                            at= "rotate%s"%spread,
                            dv = 0,
                            v = 0 )
            pm.setDrivenKeyframe( allJoints[x], 
                            cd=control + '.spread_all',
                            at= "rotate%s"%spread,
                            dv = 10,
                            v = 50 )
            """
            x += 1 
             
         
        
        
        
        
        
        
        
        
        
        pm.select(clear=True) 
        
    _connectToSH( newJnts, originalJnts )
    
    # connecting to hand jnt if passed
    if parentJnt:
        _connectToHandJnt( parentJnt, newJnts, offsetGrpsLists)
    
    pymelLogger.debug('End: build()...')