Пример #1
0
 def targetConnect(self, target, ctl, base ):
     
     cmds.connectAttr( target+'.wm', base+'.arrow[1].aimMatrix' )
     
     beforeMatrixDcmpNode = self.getBeforeMatrixDcmpNode( target )
     
     if beforeMatrixDcmpNode:
         fnc.tryConnect( beforeMatrixDcmpNode+'.ot', base+'.t' )
         fnc.tryConnect( beforeMatrixDcmpNode+'.or', base+'.r' )
         cmds.connectAttr( base+'.wm', base+'.arrow[0].aimMatrix' )
         
     cmds.connectAttr( ctl+'.t', base+'.arrow[1].offset' )
     
     retargetNodes = self.getRetargetNodes( target )
     
     for retargetNode in retargetNodes:
         
         fnc.clearArrayElement( retargetNode+'.localData' )
         index = fnc.getLastIndex( retargetNode+'.localData' )+1
         
         cmds.connectAttr( base+'.wm', retargetNode+'.localData[%d].localMatrix' % index )
         try:
             cmds.connectAttr( ctl+'.m', retargetNode+'.localData[%d].localInOffset' % index )
         except:
             cmds.connectAttr( ctl+'.m', retargetNode+'.localData[%d].localOffset' % index )
Пример #2
0
    def targetConnect(self, target, ctl, base):

        cmds.connectAttr(target + '.wm', base + '.arrow[1].aimMatrix')

        beforeMatrixDcmpNode = self.getBeforeMatrixDcmpNode(target)

        if beforeMatrixDcmpNode:
            fnc.tryConnect(beforeMatrixDcmpNode + '.ot', base + '.t')
            fnc.tryConnect(beforeMatrixDcmpNode + '.or', base + '.r')
            cmds.connectAttr(base + '.wm', base + '.arrow[0].aimMatrix')

        cmds.connectAttr(ctl + '.t', base + '.arrow[1].offset')

        retargetNodes = self.getRetargetNodes(target)

        for retargetNode in retargetNodes:

            fnc.clearArrayElement(retargetNode + '.localData')
            index = fnc.getLastIndex(retargetNode + '.localData') + 1

            cmds.connectAttr(
                base + '.wm',
                retargetNode + '.localData[%d].localMatrix' % index)
            try:
                cmds.connectAttr(
                    ctl + '.m',
                    retargetNode + '.localData[%d].localInOffset' % index)
            except:
                cmds.connectAttr(
                    ctl + '.m',
                    retargetNode + '.localData[%d].localOffset' % index)
Пример #3
0
    def targetConnect(self, target, ctl, base):

        cmds.connectAttr(target + '.wm', base + '.arrow[1].aimMatrix')

        cmds.connectAttr(base + '.wm', base + '.arrow[0].aimMatrix')

        cmds.connectAttr(ctl + '.t', base + '.arrow[1].offset')

        retargetNodes = self.getRetargetNodes(target)

        for retargetNode in retargetNodes:

            fnc.clearArrayElement(retargetNode + '.localData')
            index = fnc.getLastIndex(retargetNode + '.localData') + 1

            cmds.connectAttr(
                ctl + '.wm',
                retargetNode + '.localData[%d].localMatrix' % index)

            if not cmds.attributeQuery('localMult', node=ctl, ex=1):
                selList = om.MSelectionList()
                selList.add(ctl)

                mObj = om.MObject()
                selList.getDependNode(0, mObj)

                nAttr = om.MFnNumericAttribute()

                aAttrX = nAttr.create("localMultX", "localMultX",
                                      om.MFnNumericData.kDouble, 1.0)
                nAttr.setMin(0.0)
                aAttrY = nAttr.create("localMultY", "localMultY",
                                      om.MFnNumericData.kDouble, 1.0)
                nAttr.setMin(0.0)
                aAttrZ = nAttr.create("localMultZ", "localMultZ",
                                      om.MFnNumericData.kDouble, 1.0)
                nAttr.setMin(0.0)
                aAttr = nAttr.create('localMult', 'localMult', aAttrX, aAttrY,
                                     aAttrZ)
                nAttr.setKeyable(True)
                nAttr.setStorable(True)

                modify = om.MDGModifier()
                modify.addAttribute(mObj, aAttr)
                modify.doIt()

            if not cmds.attributeQuery('localMultOrient', node=ctl, ex=1):
                cmds.addAttr(ctl, ln='localMultOrient', min=0, dv=1)
                cmds.setAttr(ctl + '.localMultOrient', e=1, k=1)

            try:
                cmds.connectAttr(
                    ctl + '.localMult',
                    retargetNode + '.localData[%d].localMult' % index)
            except:
                cmds.connectAttr(
                    ctl + '.localMultOrient',
                    retargetNode + '.localData[%d].localMult' % index)
Пример #4
0
 def createSphere(self):
     
     sphereNode = cmds.createNode( "polySphere" )
     
     cmds.setAttr( sphereNode+'.subdivisionsAxis', 32 )
     cmds.setAttr( sphereNode+'.subdivisionsHeight', 16 )
     
     fnc.clearArrayElement( self._node+'.arrow' )
     elementNum = fnc.getLastIndex( self._node+'.arrow' )+1
     
     cmds.connectAttr( sphereNode+'.output', self._node+'.arrow[%d].inputMesh' % elementNum )
Пример #5
0
    def targetConnect(self, target, ctl, base ):
        
        cmds.connectAttr( target+'.wm', base+'.arrow[1].aimMatrix' )
        
        beforeMatrixNode = self.getBeforeMatrixNode( target )
        
        if beforeMatrixNode:
            cmds.connectAttr( beforeMatrixNode+'.o', base+'.arrow[0].aimMatrix' )
            
        cmds.connectAttr( ctl+'.t', base+'.arrow[1].offset' )
        retargetNodes = self.getRetargetNodes( target )
        
        for retargetNode in retargetNodes:
            
            fnc.clearArrayElement( retargetNode+'.localData' )
            index = fnc.getLastIndex( retargetNode+'.localData' )+1
            
            cmds.connectAttr( base+'.wm', retargetNode+'.localData[%d].localMatrix' % index )
            try:
                cmds.connectAttr( ctl+'.m', retargetNode+'.localData[%d].localOutOffset' % index )
            except:
                cmds.connectAttr( ctl+'.m', retargetNode+'.localData[%d].localOffset' % index )
            
            if not cmds.attributeQuery( 'localMult', node=base, ex=1 ):
                selList = om.MSelectionList()
                selList.add( base )
                
                mObj = om.MObject()
                selList.getDependNode( 0, mObj )

                nAttr = om.MFnNumericAttribute()
                
                aAttrX = nAttr.create( "localMultX", "localMultX", om.MFnNumericData.kDouble, 1.0 )
                nAttr.setMin( 0.0 )
                aAttrY = nAttr.create( "localMultY", "localMultY", om.MFnNumericData.kDouble, 1.0 )
                nAttr.setMin( 0.0 )
                aAttrZ = nAttr.create( "localMultZ", "localMultZ", om.MFnNumericData.kDouble, 1.0 )
                nAttr.setMin( 0.0 )
                aAttr = nAttr.create( 'localMult','localMult', aAttrX, aAttrY, aAttrZ )
                nAttr.setKeyable( True )
                nAttr.setStorable( True )
            
                modify = om.MDGModifier()
                modify.addAttribute( mObj, aAttr )
                modify.doIt()
                
            if not cmds.attributeQuery( 'localMultOrient', node=base, ex=1 ):
                cmds.addAttr( base, ln='localMultOrient', min=0, dv=1 )
                cmds.setAttr( base+'.localMultOrient', e=1, k=1 )
            
            try: 
                cmds.connectAttr( base+'.localMult', retargetNode+'.localData[%d].localMult' % index )
            except:
                cmds.connectAttr( base+'.localMultOrient', retargetNode+'.localData[%d].localMult' % index )
Пример #6
0
    def createSphere(self):

        sphereNode = cmds.createNode("polySphere")

        cmds.setAttr(sphereNode + '.subdivisionsAxis', 32)
        cmds.setAttr(sphereNode + '.subdivisionsHeight', 16)

        fnc.clearArrayElement(self._node + '.arrow')
        elementNum = fnc.getLastIndex(self._node + '.arrow') + 1

        cmds.connectAttr(sphereNode + '.output',
                         self._node + '.arrow[%d].inputMesh' % elementNum)
Пример #7
0
def clearLocalData( target ):
    
    orientNodeCons = cmds.listConnections( target, type='retargetOrientNode' )
    transNodeCons = cmds.listConnections( target, type='retargetTransNode' )
    
    retargetNodes = []
    
    if orientNodeCons:
        retargetNodes.append( orientNodeCons[0] )
    if transNodeCons:
        retargetNodes.append( transNodeCons[0] )
        
    if retargetNodes:
        
        for retargetNode in retargetNodes:
            fnc.clearArrayElement( retargetNode+'.localData' )
Пример #8
0
    def getBeforeMatrixNode(self, target):

        retargetNodes = self.getRetargetNodes(target)
        targetP = fnc.getP(target)

        duRetargetNodes = []

        for retargetNode in retargetNodes:

            duRetargetNode = cmds.duplicate(retargetNode)[0]

            cons = cmds.listConnections(retargetNode, s=1, d=0, p=1, c=1)

            outputs = cons[1::2]
            inputs = cons[::2]

            for i in range(len(outputs)):
                inputAttr = inputs[i].replace(retargetNode, duRetargetNode)
                cmds.connectAttr(outputs[i], inputAttr)

            duRetargetNodes.append(duRetargetNode)

        if duRetargetNodes:

            combineNode = cmds.createNode('transRotateCombineMatrix')
            beforeMatrixNode = cmds.createNode('multMatrix')

            for duRetargetNode in duRetargetNodes:

                fnc.clearArrayElement(duRetargetNode + '.localData')

                if cmds.nodeType(duRetargetNode) == 'retargetTransNode':
                    cmds.connectAttr(duRetargetNode + '.transMatrix',
                                     combineNode + '.inputTransMatrix')
                if cmds.nodeType(duRetargetNode) == 'retargetOrientNode':
                    cmds.connectAttr(duRetargetNode + '.orientMatrix',
                                     combineNode + '.inputRotateMatrix')

            cmds.connectAttr(combineNode + '.outputMatrix',
                             beforeMatrixNode + '.i[0]')
            cmds.connectAttr(targetP + '.wm', beforeMatrixNode + '.i[1]')

            return beforeMatrixNode
Пример #9
0
    def create3Torus(self):

        axisList = ['axisX', 'axisY', 'axisZ']

        fnc.clearArrayElement(self._node + '.shapes')
        elementNum = fnc.getLastIndex(self._node + '.shapes') + 1

        for i in range(3):
            torus = cmds.createNode("polyTorus")

            cmds.setAttr(torus + '.sectionRadius', 0.05)
            cmds.setAttr(torus + '.subdivisionsHeight', 8)
            cmds.setAttr(torus + '.subdivisionsAxis', 32)

            cmds.setAttr(torus + '.' + axisList[i], .9)
            cmds.setAttr(torus + '.' + axisList[(i + 1) % 3], 0)
            cmds.setAttr(torus + '.' + axisList[(i + 2) % 3], 0)

            cmds.connectAttr(
                torus + '.output',
                self._node + '.shapes[%d].inputMesh' % (elementNum + i))
Пример #10
0
 def getBeforeMatrixNode(self, target ):
     
     retargetNodes = self.getRetargetNodes( target )
     targetP = fnc.getP( target )
         
     duRetargetNodes = []
     
     for retargetNode in retargetNodes:
         
         duRetargetNode= cmds.duplicate( retargetNode )[0]
         
         cons = cmds.listConnections( retargetNode, s=1, d=0, p=1, c=1 )
         
         outputs= cons[1::2]
         inputs = cons[::2]
         
         for i in range( len( outputs ) ):
             inputAttr = inputs[i].replace( retargetNode, duRetargetNode )
             cmds.connectAttr( outputs[i], inputAttr )
             
         duRetargetNodes.append( duRetargetNode )
             
     if duRetargetNodes:
     
         combineNode = cmds.createNode( 'transRotateCombineMatrix' )
         beforeMatrixNode = cmds.createNode( 'multMatrix' )
     
         for duRetargetNode in duRetargetNodes:
             
             fnc.clearArrayElement( duRetargetNode+'.localData' )
             
             if cmds.nodeType( duRetargetNode ) == 'retargetTransNode':
                 cmds.connectAttr( duRetargetNode+'.transMatrix', combineNode+'.inputTransMatrix' )
             if cmds.nodeType( duRetargetNode ) == 'retargetOrientNode':
                 cmds.connectAttr( duRetargetNode+'.orientMatrix', combineNode+'.inputRotateMatrix' )
         
         cmds.connectAttr( combineNode+'.outputMatrix', beforeMatrixNode+'.i[0]' )
         cmds.connectAttr( targetP+'.wm', beforeMatrixNode+'.i[1]' )
                 
         return beforeMatrixNode
Пример #11
0
 def create3Torus(self):
     
     fnc.clearArrayElement( self._node+'.shapes' )
     
     for i in range( 3 ):
         self.createTorus( i )
Пример #12
0
def disconnect( sourceWorldCtl, targetWorldCtl ):
    
    def deleteFollowWeightAttrs( tr ):
        udAttrs = cmds.listAttr( tr, k=1, ud=1 )
        
        if not udAttrs: return None
        
        for attr in udAttrs:
            if attr[-5:] == 'CTL_w':
                cmds.deleteAttr( tr+'.'+attr )
                
    def disconnectOutWeight( sourceNS, targetNS ):
        timeControl = timeCmd.getTimeControl( targetNS+'World_CTL', [sourceNS+'World_CTL'] )[0]
        
        if not timeControl: return None
        outWeights = cmds.listConnections( timeControl+'.outWeight', s=0, d=1, c=1, p=1 )
        
        if not outWeights: return None
        
        outputs = outWeights[::2]
        inputs  = outWeights[1::2]
        
        for i in range( len( outputs ) ):
            if inputs[i].find( targetNS ) == 0:
                cmds.disconnectAttr( outputs[i], inputs[i] )
                
    def deleteDistRate( sourceNS, targetNS ):
        distRates = cmds.ls( sourceNS+'*_distRate' )
        
        connectedAttrs = []
        for distRate in distRates:
            cons = cmds.listConnections( distRate+'.message', d=1, s=0, p=1, c=1 )
            
            if not cons: continue
            inputs  = cons[1::2]
            outputs = cons[::2]
            for i in range( len( inputs ) ):
                cmds.disconnectAttr( outputs[i], inputs[i] )
            
            connectedAttrs += inputs
        
        cmds.delete( distRate )
        
        for connectedAttr in connectedAttrs:
            mel.eval( "removeMultiInstance %s" % connectedAttr )
            
    localCtlInst = editTransform.localControler( sourceWorldCtl, targetWorldCtl )
    
    localCtls = localCtlInst.getLocalControler()
    
    for localCtl in localCtls:
        localCtlInst.deleteLocalControler( localCtl )
    
    sourceNS = sourceWorldCtl.replace( 'World_CTL', '' )
    targetNS = targetWorldCtl.replace( 'World_CTL', '' )
    
    disconnectOutWeight( sourceNS, targetNS )
    deleteDistRate( sourceNS, targetNS )
    
    retargetTrans = cmds.ls( sourceNS+'*', type='retargetTransNode' )
    retargetOrient = cmds.ls( sourceNS+'*', type='retargetOrientNode' )
    
    if retargetTrans:
        cmds.delete( retargetTrans )
    if retargetOrient:
        cmds.delete( retargetOrient )
        
    retargetBlenders = cmds.ls( targetNS+'*', type='retargetBlender' )
    udAttrBlenders   = cmds.ls( targetNS+'*', type='udAttrBlender' )
    
    if udAttrBlenders:
        for udAttrBlender in udAttrBlenders:
            cons = cmds.listConnections( udAttrBlender, s=1, d=0, c=1, p=1 )
            
            if not cons: 
                cmds.delete( udAttrBlender )
                continue
            
            outputs = cons[1::2]
            inputs = cons[::2]
            
            for i in range( len( outputs ) ):
                if outputs[i].find( sourceNS.replace( 'DGTR_','' ) ) == 0:
                    cmds.disconnectAttr( outputs[i], inputs[i] )
            
            fnc.clearArrayElement( udAttrBlender+'.input' )
            if fnc.getLastIndex( udAttrBlender+'.input' ) == -1:
                cmds.delete( udAttrBlender )
    
    if retargetBlenders:
        for retargetBlender in retargetBlenders:
            fnc.clearArrayElement( retargetBlender+'.input' )
            if not cmds.listConnections( retargetBlender, s=1, d=0, type='retargetTransNode' ):
                trCons = cmds.listConnections( retargetBlender, s=0, d=1 )
                if trCons:
                    deleteFollowWeightAttrs( trCons[0] )
                cmds.delete( retargetBlender )
                
    multNodes   = cmds.ls( sourceNS+'*', type='multiplyDivide' )
    multNodes  += cmds.ls( targetNS+'*', type='multiplyDivide' )
    
    if multNodes:
        cmds.delete( multNodes )
Пример #13
0
def getConnectedRetargetWorldCtl( targetWorldCtl ):
    
    worldCtlList = getWorldCtlList()
    if targetWorldCtl in worldCtlList:
        worldCtlList.remove( targetWorldCtl )
    
    retargetNSs = []
    
    sourceNSs = []
    
    for worldCtl in worldCtlList:
        sourceNSs.append( worldCtl.replace( 'World_CTL', '' ) )
    if not sourceNSs: return None
    
    targetNS = targetWorldCtl.replace( 'World_CTL', '' )
    
    targetCtls = cmds.ls( targetNS+'*_CTL', tr=1 )
    
    for ctl in targetCtls:
        
        retargetBlenderCons = cmds.listConnections( ctl, type='retargetBlender', s=1, d=0 )
        retargetUdAttrCons  = cmds.listConnections( ctl, type='udAttrBlender', s=1, d=0 )
        
        if retargetBlenderCons:
            retargetBlender = retargetBlenderCons[0]
            
            fnc.clearArrayElement( retargetBlender+'.input' )
            inputLen = fnc.getLastIndex( retargetBlender+'.input' )+1
    
            originName = ctl.replace( targetNS, '' )
            
            for i in range( inputLen ):
                RTTrans = cmds.listConnections( retargetBlender+'.input[%d].transMatrix' % i )
                if not RTTrans: continue
                
                RTTrans = RTTrans[0].split( '_RTTrans' )[0]
                
                RTNamespace = RTTrans.replace( originName, '' )
                
                if RTNamespace in sourceNSs:
                    retargetNSs.append( RTNamespace+'World_CTL' )
                    sourceNSs.remove( RTNamespace )
                    
        if retargetUdAttrCons:
            retargetUdAttr = retargetUdAttrCons[0]
            
            fnc.clearArrayElement( retargetUdAttr+'.input' )
            inputLen = fnc.getLastIndex( retargetUdAttr+'.input' )+1
    
            originName = ctl.replace( targetNS, '' )
            
            for i in range( inputLen ):
                inputAnimNodes = cmds.listConnections( retargetUdAttr+'.input[%d].udAttr[0]' % i )
                if not inputAnimNodes: continue
                
                udNamespace = inputAnimNodes[0].split( originName )[0]+'DGTR_'

                if udNamespace in sourceNSs:
                    retargetNSs.append( udNamespace+'World_CTL' )
                    sourceNSs.remove( udNamespace )
    
    return retargetNSs
Пример #14
0
def getTimeControl( targetWorldCtl, worldCtlList ):
    
    retargetNSs = []
    
    sourceNSs = []
    
    for worldCtl in worldCtlList:
        sourceNSs.append( worldCtl.replace( 'World_CTL', '' ) )
    
    targetNS = targetWorldCtl.replace( 'World_CTL', '' )
    
    targetCtls = cmds.ls( targetNS+'*_CTL', tr=1 )
    
    for ctl in targetCtls:
        
        if not sourceNSs: break
        
        retargetBlenderCons = cmds.listConnections( ctl, type='retargetBlender', s=1, d=0 )
        if retargetBlenderCons:
            retargetBlender = retargetBlenderCons[0]
            
            fnc.clearArrayElement( retargetBlender+'.input' )
            inputLen = fnc.getLastIndex( retargetBlender+'.input' )+1
            
            originName = ctl.replace( targetNS, '' )
            
            for i in range( inputLen ):
                RTTrans = cmds.listConnections( retargetBlender+'.input[%d].transMatrix' % i )
                if not RTTrans: continue
                
                RTTrans = RTTrans[0].split( '_RTTrans' )[0]
                
                RTNamespace = RTTrans.replace( originName, '' )
                
                if RTNamespace in sourceNSs:
                    timeControls = cmds.ls( RTNamespace.replace( 'DGTR_', '' )+'timeControl*' )
                    if not timeControls: "%s Motion File has no timeControl." % RTNamespace
                    cuTimeControl = None
                    for timeControl in timeControls:
                        if cmds.nodeType( timeControl ) == 'timeControl':
                            cuTimeControl = timeControl
                    retargetNSs.append( cuTimeControl )
                    sourceNSs.remove( RTNamespace )
                    
        udAttrBlenderCons = cmds.listConnections( ctl, type='udAttrBlender', s=1, d=0 )
                    
        if udAttrBlenderCons:
            retargetUdAttr = udAttrBlenderCons[0]
            
            fnc.clearArrayElement( retargetUdAttr+'.input' )
            inputLen = fnc.getLastIndex( retargetUdAttr+'.input' )+1
    
            originName = ctl.replace( targetNS, '' )
            
            for i in range( inputLen ):
                inputAnimNodes = cmds.listConnections( retargetUdAttr+'.input[%d].udAttr[0]' % i )
                if not inputAnimNodes: continue
                
                udNamespace = inputAnimNodes[0].split( originName )[0]+'DGTR_'

                if udNamespace in sourceNSs:
                    timeControls = cmds.ls( udNamespace.replace( 'DGTR_', '' )+'timeControl*' )
                    if not timeControls: "%S Motion File has no timeControl." % udNamespace
                    cuTimeControl = None
                    for timeControl in timeControls:
                        if cmds.nodeType( timeControl ) == 'timeControl':
                            cuTimeControl = timeControl
                    retargetNSs.append( cuTimeControl )
                    sourceNSs.remove( udNamespace )
        
    return retargetNSs
Пример #15
0
def getConnectedRetargetWorldCtl(targetWorldCtl):

    worldCtlList = getWorldCtlList()
    if targetWorldCtl in worldCtlList:
        worldCtlList.remove(targetWorldCtl)

    retargetNSs = []

    sourceNSs = []

    for worldCtl in worldCtlList:
        sourceNSs.append(worldCtl.replace('World_CTL', ''))
    if not sourceNSs: return None

    targetNS = targetWorldCtl.replace('World_CTL', '')

    targetCtls = cmds.ls(targetNS + '*_CTL', tr=1)

    for ctl in targetCtls:

        retargetBlenderCons = cmds.listConnections(ctl,
                                                   type='retargetBlender',
                                                   s=1,
                                                   d=0)
        retargetUdAttrCons = cmds.listConnections(ctl,
                                                  type='udAttrBlender',
                                                  s=1,
                                                  d=0)

        if retargetBlenderCons:
            retargetBlender = retargetBlenderCons[0]

            fnc.clearArrayElement(retargetBlender + '.input')
            inputLen = fnc.getLastIndex(retargetBlender + '.input') + 1

            originName = ctl.replace(targetNS, '')

            for i in range(inputLen):
                RTTrans = cmds.listConnections(retargetBlender +
                                               '.input[%d].transMatrix' % i)
                if not RTTrans: continue

                RTTrans = RTTrans[0].split('_RTTrans')[0]

                RTNamespace = RTTrans.replace(originName, '')

                if RTNamespace in sourceNSs:
                    retargetNSs.append(RTNamespace + 'World_CTL')
                    sourceNSs.remove(RTNamespace)

        if retargetUdAttrCons:
            retargetUdAttr = retargetUdAttrCons[0]

            fnc.clearArrayElement(retargetUdAttr + '.input')
            inputLen = fnc.getLastIndex(retargetUdAttr + '.input') + 1

            originName = ctl.replace(targetNS, '')

            for i in range(inputLen):
                inputAnimNodes = cmds.listConnections(retargetUdAttr +
                                                      '.input[%d].udAttr[0]' %
                                                      i)
                if not inputAnimNodes: continue

                udNamespace = inputAnimNodes[0].split(originName)[0] + 'DGTR_'

                if udNamespace in sourceNSs:
                    retargetNSs.append(udNamespace + 'World_CTL')
                    sourceNSs.remove(udNamespace)

    return retargetNSs
Пример #16
0
def disconnect(sourceWorldCtl, targetWorldCtl):
    def deleteFollowWeightAttrs(tr):
        udAttrs = cmds.listAttr(tr, k=1, ud=1)

        if not udAttrs: return None

        for attr in udAttrs:
            if attr[-5:] == 'CTL_w':
                cmds.deleteAttr(tr + '.' + attr)

    def disconnectOutWeight(sourceNS, targetNS):
        timeControl = timeCmd.getTimeControl(targetNS + 'World_CTL',
                                             [sourceNS + 'World_CTL'])[0]

        if not timeControl: return None
        outWeights = cmds.listConnections(timeControl + '.outWeight',
                                          s=0,
                                          d=1,
                                          c=1,
                                          p=1)

        if not outWeights: return None

        outputs = outWeights[::2]
        inputs = outWeights[1::2]

        for i in range(len(outputs)):
            if inputs[i].find(targetNS) == 0:
                cmds.disconnectAttr(outputs[i], inputs[i])

    def deleteDistRate(sourceNS, targetNS):
        distRates = cmds.ls(sourceNS + '*_distRate')

        connectedAttrs = []
        for distRate in distRates:
            cons = cmds.listConnections(distRate + '.message',
                                        d=1,
                                        s=0,
                                        p=1,
                                        c=1)

            if not cons: continue
            inputs = cons[1::2]
            outputs = cons[::2]
            for i in range(len(inputs)):
                cmds.disconnectAttr(outputs[i], inputs[i])

            connectedAttrs += inputs

        cmds.delete(distRate)

        for connectedAttr in connectedAttrs:
            mel.eval("removeMultiInstance %s" % connectedAttr)

    localCtlInst = editTransform.localControler(sourceWorldCtl, targetWorldCtl)

    localCtls = localCtlInst.getLocalControler()

    for localCtl in localCtls:
        localCtlInst.deleteLocalControler(localCtl)

    sourceNS = sourceWorldCtl.replace('World_CTL', '')
    targetNS = targetWorldCtl.replace('World_CTL', '')

    disconnectOutWeight(sourceNS, targetNS)
    deleteDistRate(sourceNS, targetNS)

    retargetTrans = cmds.ls(sourceNS + '*', type='retargetTransNode')
    retargetOrient = cmds.ls(sourceNS + '*', type='retargetOrientNode')

    if retargetTrans:
        cmds.delete(retargetTrans)
    if retargetOrient:
        cmds.delete(retargetOrient)

    retargetBlenders = cmds.ls(targetNS + '*', type='retargetBlender')
    udAttrBlenders = cmds.ls(targetNS + '*', type='udAttrBlender')

    if udAttrBlenders:
        for udAttrBlender in udAttrBlenders:
            cons = cmds.listConnections(udAttrBlender, s=1, d=0, c=1, p=1)

            if not cons:
                cmds.delete(udAttrBlender)
                continue

            outputs = cons[1::2]
            inputs = cons[::2]

            for i in range(len(outputs)):
                if outputs[i].find(sourceNS.replace('DGTR_', '')) == 0:
                    cmds.disconnectAttr(outputs[i], inputs[i])

            fnc.clearArrayElement(udAttrBlender + '.input')
            if fnc.getLastIndex(udAttrBlender + '.input') == -1:
                cmds.delete(udAttrBlender)

    if retargetBlenders:
        for retargetBlender in retargetBlenders:
            fnc.clearArrayElement(retargetBlender + '.input')
            if not cmds.listConnections(
                    retargetBlender, s=1, d=0, type='retargetTransNode'):
                trCons = cmds.listConnections(retargetBlender, s=0, d=1)
                if trCons:
                    deleteFollowWeightAttrs(trCons[0])
                cmds.delete(retargetBlender)

    multNodes = cmds.ls(sourceNS + '*', type='multiplyDivide')
    multNodes += cmds.ls(targetNS + '*', type='multiplyDivide')

    if multNodes:
        cmds.delete(multNodes)
Пример #17
0
    def create3Torus(self):

        fnc.clearArrayElement(self._node + '.shapes')

        for i in range(3):
            self.createTorus(i)