Exemple #1
0
    def test_instance_from_meta(self):
        component1 = AnimComponent.create()
        new_component = AnimComponent(component1.pynode.name())

        # Assertions
        # Structs
        self.assertEqual(new_component.name, "anim_component")
        self.assertEqual(new_component.side, "c")

        # Metanode
        self.assertEqual(
            str(new_component.pynode),
            "{0}_{1}_00_meta".format(new_component.side, new_component.name))
        self.assertEqual(new_component.pynode.metaRigType.get(),
                         AnimComponent.as_str())
        self.assertEqual(new_component.pynode.version.get(), 1)
        self.assertEqual(
            str(new_component.root),
            "{0}_{1}_00_comp".format(new_component.side, new_component.name))
        self.assertEqual(
            str(new_component.group_ctls),
            "{0}_{1}_00_ctls".format(new_component.side, new_component.name))
        self.assertEqual(
            str(new_component.group_joints),
            "{0}_{1}_00_jnts".format(new_component.side, new_component.name))
        self.assertEqual(
            str(new_component.group_parts),
            "{0}_{1}_00_parts".format(new_component.side, new_component.name))

        # Meta parent attrs on hierarchy
        self.assertTrue(pm.hasAttr(new_component.root, "metaParent"))
        self.assertTrue(pm.hasAttr(new_component.group_ctls, "metaParent"))
        self.assertTrue(pm.hasAttr(new_component.group_joints, "metaParent"))
        self.assertTrue(pm.hasAttr(new_component.group_parts, "metaParent"))

        # Attributes on meta node
        self.assertTrue(pm.hasAttr(new_component.pynode, "rootGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "ctlsGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "jointsGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "partsGroup"))

        # Connections to metanode
        self.assertTrue(
            pm.isConnected(new_component.root.metaParent,
                           new_component.pynode.rootGroup))
        self.assertTrue(
            pm.isConnected(new_component.group_ctls.metaParent,
                           new_component.pynode.ctlsGroup))
        self.assertTrue(
            pm.isConnected(new_component.group_joints.metaParent,
                           new_component.pynode.jointsGroup))
        self.assertTrue(
            pm.isConnected(new_component.group_parts.metaParent,
                           new_component.pynode.partsGroup))

        # Save test scene
        pm.renameFile(
            self.get_temp_filename(
                "anim_component_test_instance_from_meta.ma"))
        pm.saveFile(f=1)
    def test_clusterPlane(self):
        fr = FollowRibbon.FollowRibbon(name="blah")
        plane = pm.nurbsPlane(axis=[0, 1, 0], patchesU=8, patchesV=1, lengthRatio=0.1, ch=0)[0]
        ctrls = []
        ctrls.append(pm.circle(n="blah_ctrl_01")[0].name())
        ctrls.append(pm.circle(n="blah_ctrl_02")[0].name())
        mainGrp = pm.group(em=1, name="main")

        result = fr._clusterPlane(plane=plane, controls=ctrls, mainGrp="main")

        self.testLib.assertListEqual(result, ["blah_cluster_01Handle", "blah_cluster_02Handle"])
        self.assertTrue(pm.objExists("blah_cluster_01"))
        self.assertTrue(pm.objExists("blah_cluster_02"))

        self.assertTrue(pm.listRelatives(result[0], parent=True), "main")
        self.assertTrue(pm.listRelatives(result[1], parent=True), "main")

        self.assertTrue(pm.listRelatives(result[0], parent=1)[0], "blah_ctrlsGrp")
        self.assertTrue(pm.listRelatives(result[1], parent=1)[0], "blah_ctrlsGrp")

        hist = pm.listHistory(plane)
        hitA = 0
        hitB = 0
        for each in hist:
            if each.name() == "blah_cluster_01":
                hitA = 1
            if each.name() == "blah_cluster_02":
                hitB = 1
        self.assertTrue(hitA)
        self.assertTrue(hitB)

        self.assertTrue(pm.isConnected("blah_ctrl_01.translate", "blah_cluster_01Handle.translate"))
        self.assertTrue(pm.isConnected("blah_ctrl_02.translate", "blah_cluster_02Handle.translate"))
Exemple #3
0
def matchJoints(source, destination):
    """ Tags the source as a match of the destination. """
    if not source.hasAttr(MATCH_ATTR_NAME):
        source.addAttr(MATCH_ATTR_NAME, at='message')
    if not destination.hasAttr(MATCH_ATTR_NAME):
        destination.addAttr(MATCH_ATTR_NAME, at='message')
    if not pmc.isConnected(source.message, destination.attr(MATCH_ATTR_NAME)):
        source.message.connect(destination.attr(MATCH_ATTR_NAME), force=True)
    if not pmc.isConnected(destination.message, source.attr(MATCH_ATTR_NAME)):
        destination.message.connect(source.attr(MATCH_ATTR_NAME), force=True)
    def test_createDriveControls(self):
        fr = FollowRibbon.FollowRibbon(name="blah")
        plane = pm.nurbsPlane(axis=[0, 1, 0], patchesU=8, patchesV=1, lengthRatio=0.1, ch=0)[0]
        grps, jnts, cposNodes = fr._createPlaneControls(plane=plane, direction="u", number=4)

        mainGrp, ctrls = fr._createDriveControls(grps=grps, cposNodes=cposNodes)

        self.assertEqual(mainGrp, "blah_ctrlsGrp")
        self.testLib.assertListEqual(ctrls, ["blah_ctrl_01", "blah_ctrl_02", "blah_ctrl_03", "blah_ctrl_04"])

        for index in range(4):
            self.assertTrue(pm.objExists("blah_ctrlTopGrp_%s" % str(index + 1).zfill(2)))
            self.assertTrue(pm.objExists("blah_ctrlMidGrp_%s" % str(index + 1).zfill(2)))
            self.assertTrue(pm.objExists("blah_ctrlBtmGrp_%s" % str(index + 1).zfill(2)))
            self.assertTrue(pm.objExists("blah_InvertMdNode_%s" % str(index + 1).zfill(2)))
            self.assertTrue(pm.objExists("blah_ctrl_%s" % str(index + 1).zfill(2)))

            self.assertEqual(
                pm.listRelatives("blah_ctrlTopGrp_%s" % str(index + 1).zfill(2), parent=1)[0].name(), "blah_ctrlsGrp"
            )

            self.testLib.assertConstrained(
                grps[index].name(), "blah_ctrlTopGrp_%s" % str(index + 1).zfill(2), type="parent"
            )

            self.assertTrue(
                pm.isConnected(
                    "blah_ctrl_%s.translate" % str(index + 1).zfill(2),
                    "blah_InvertMdNode_%s.input1" % str(index + 1).zfill(2),
                )
            )
            self.assertTrue(
                pm.isConnected(
                    "blah_InvertMdNode_%s.output" % str(index + 1).zfill(2),
                    "blah_ctrlBtmGrp_%s.translate" % str(index + 1).zfill(2),
                )
            )

            self.assertTrue(pm.objExists("blah_ctrl_%s.uParam" % str(index + 1).zfill(2)))
            self.assertTrue(pm.objExists("blah_ctrl_%s.vParam" % str(index + 1).zfill(2)))

            self.assertTrue(
                pm.isConnected(
                    "blah_ctrl_%s.uParam" % str(index + 1).zfill(2),
                    "blah_drvCPOS_%s.parameterU" % str(index + 1).zfill(2),
                )
            )
            self.assertTrue(
                pm.isConnected(
                    "blah_ctrl_%s.vParam" % str(index + 1).zfill(2),
                    "blah_drvCPOS_%s.parameterV" % str(index + 1).zfill(2),
                )
            )
Exemple #5
0
    def mirrorNode(self, sourceNode, destNode, isNewNode):
        """
        Change the parent of destNode to match that of sourceNode,
        ensuring the use of paired nodes where possible to preserve
        a mirrored parenting structure.

        Handles joint parenting specially by checking for centered
        parents along an axis, as well as connecting inverse scales
        so that segment scale compensate still works.
        """
        with preservedSelection():
            # get parent of source node
            if self.findCenteredJoints and isinstance(sourceNode, pm.nt.Joint):
                srcParent = getMirroredOrCenteredParent(sourceNode, self.axis)
            else:
                srcParent = sourceNode.getParent()

            if srcParent:
                dstParent = getPairedNode(srcParent)
                if dstParent:
                    self.setParent(destNode, dstParent)
                else:
                    self.setParent(destNode, srcParent)
            else:
                self.setParent(destNode, None)

            # handle joint reparenting
            if isinstance(destNode, pm.nt.Joint):
                p = destNode.getParent()
                if p and isinstance(p, pm.nt.Joint):
                    if not pm.isConnected(p.scale, destNode.inverseScale):
                        p.scale >> destNode.inverseScale
Exemple #6
0
def connect_construction_history(connector=None, nodes=[]):
    """Retrieve and connect construction history of specified nodes or all.

    :param connector: Control which switches ihi attr of connected node
    :type connector: str

    :param nodes: Nodes to connect their isHistoricallyInteresting attr
    :type nodes: list of maya dg and dag nodes

    :return pyNode of the connector storing the showHistory attribute
    """

    if not nodes:
        nodes = pm.ls()
    else:
        nodes = [pm.PyNode(node) for node in nodes]

    if not connector:
        if not pm.objExists('ConstructionHistory'):
            connector = pm.createNode('transform', n='ConstructionHistory')
        else:
            connector = pm.PyNode('ConstructionHistory')
    else:
        connector = pm.PyNode(connector)

    if not pm.objExists('%s.showHistory' % connector):
        connector.addAttr('showHistory', at='short', min=0, max=1)
        connector.showHistory.set(e=True, cb=True)

    for node in nodes:
        if not pm.isConnected(connector.showHistory, node.ihi):
            connector.showHistory >> node.ihi
    return connector
Exemple #7
0
def connect_attributes(a,b):
    if pymel.isConnected(a, b) is not True:
        connection = pymel.connectAttr(a, b)
        return connection 
    else:
        print str(a) + ' is already connected to ' + str(b)
         
Exemple #8
0
    def test_clusterPlane(self):
        fr = FollowRibbon.FollowRibbon(name='blah')
        plane = pm.nurbsPlane(axis=[0, 1, 0],
                              patchesU=8,
                              patchesV=1,
                              lengthRatio=.1,
                              ch=0)[0]
        ctrls = []
        ctrls.append(pm.circle(n='blah_ctrl_01')[0].name())
        ctrls.append(pm.circle(n='blah_ctrl_02')[0].name())
        mainGrp = pm.group(em=1, name='main')

        result = fr._clusterPlane(plane=plane, controls=ctrls, mainGrp='main')

        self.testLib.assertListEqual(
            result, ['blah_cluster_01Handle', 'blah_cluster_02Handle'])
        self.assertTrue(pm.objExists('blah_cluster_01'))
        self.assertTrue(pm.objExists('blah_cluster_02'))

        self.assertTrue(pm.listRelatives(result[0], parent=True), 'main')
        self.assertTrue(pm.listRelatives(result[1], parent=True), 'main')

        self.assertTrue(
            pm.listRelatives(result[0], parent=1)[0], 'blah_ctrlsGrp')
        self.assertTrue(
            pm.listRelatives(result[1], parent=1)[0], 'blah_ctrlsGrp')

        hist = pm.listHistory(plane)
        hitA = 0
        hitB = 0
        for each in hist:
            if each.name() == 'blah_cluster_01':
                hitA = 1
            if each.name() == 'blah_cluster_02':
                hitB = 1
        self.assertTrue(hitA)
        self.assertTrue(hitB)

        self.assertTrue(
            pm.isConnected('blah_ctrl_01.translate',
                           'blah_cluster_01Handle.translate'))
        self.assertTrue(
            pm.isConnected('blah_ctrl_02.translate',
                           'blah_cluster_02Handle.translate'))
Exemple #9
0
    def test_create_with_meta_parent(self):
        component1 = AnimComponent.create()
        component2 = AnimComponent.create(meta_parent=component1)

        self.assertTrue(
            pm.isConnected(component2.pynode.metaParent,
                           component1.pynode.metaChildren[0]))
        self.assertEqual(component2.get_meta_parent(), component1)

        # Save test scene
        pm.renameFile(
            self.get_temp_filename(
                "anim_component_test_create_with_meta_parent.ma"))
        pm.saveFile(f=1)
Exemple #10
0
def assignMat(texture_name = "PC0000_00_BodyB_C", material_name = "PC0000_00_Pants", texture_folder=""):
    material = pm.ls(material_name)
    if material:
        material = material[0]
        specularRoughness = '%s.specularRoughness' % material
        specularColor = '%s.specularColor' % material
        coatColor = '%s.coatColor' % material
        coatWeight = '%s.coat' % material
        print(material.getName())
        fileNode = material.connections(type='file')
        if fileNode and "_C" in texture_name:
            for file in fileNode:
                fileOutColor = '%s.outColor' % file
                #pm.connectAttr(sphereR, coneR)
                if pm.isConnected( fileOutColor, specularColor ):
                    pm.disconnectAttr(fileOutColor, specularColor)
                if pm.isConnected( fileOutColor, coatColor ):
                    pm.disconnectAttr(fileOutColor, coatColor)
                pm.setAttr(file.fileTextureName, texture_folder+texture_name+".tga")
                textureFile = pm.getAttr(file.fileTextureName)
                print 'This is the file', str(textureFile)
                #create_hair(g, material, file, mat_name)
        bumpNode = material.connections(type='bump2d')
        if bumpNode and "_N" in texture_name:
            bumpNode= bumpNode[0]
            print(pm.getAttr(bumpNode.bumpValue))
            fileNode = bumpNode.connections(type='file')
            for file in fileNode:
                pm.setAttr(file.fileTextureName, texture_folder+texture_name+".tga")
                textureFile = pm.getAttr(file.fileTextureName)
                print 'This is the file', str(textureFile)
                #create_hair(g, material, file, mat_name)

        #set values for material
        pm.setAttr(specularColor, (1.0, 1.0, 1.0))
        pm.setAttr(specularRoughness, 0.5)
        pm.setAttr(coatWeight, 0.0)
Exemple #11
0
def connectToMasterScale(grp):
    rootCtrl = "PLACER"
    # connects rig and space switching groups (or any transform) to masterScale
    if rootCtrl == "" or pm.nodeType(grp) != "transform":
        return
    # add masterScale if it doesn't exist

    if not (pm.mel.attributeExists("masterScale", rootCtrl)):
        pm.addAttr(rootCtrl,
                   min=.001,
                   ln="masterScale",
                   max=10,
                   keyable=True,
                   at='double',
                   dv=1)

    if not (pm.isConnected((rootCtrl + ".masterScale"), (grp + ".sx"))):
        pm.connectAttr((rootCtrl + ".masterScale"), (grp + ".sx"))

    if not (pm.isConnected((rootCtrl + ".masterScale"), (grp + ".sy"))):
        pm.connectAttr((rootCtrl + ".masterScale"), (grp + ".sy"))

    if not (pm.isConnected((rootCtrl + ".masterScale"), (grp + ".sz"))):
        pm.connectAttr((rootCtrl + ".masterScale"), (grp + ".sz"))
Exemple #12
0
    def mirrorParenting(self, sourceNode, destNode=None):
        """Parent destNode to match the parenting of the given sourceNode.

        Notes:
            If sourceNode's parent is not a mirror node reparents so that
            the nodes share the same parent, this includes sourceNode
            not having any parent (parent is None).
            This also handles joint parenting, eg. connecting
            inverse scales so that segment scale compensate still works

            `opts` used:
                `handleJoints` -- Whether to handle joints specially or not if True, reparents to next highest centered or mirrored parent.
                `axis` -- Used when handling joints to determine if they are centered.

        Args:
            sourceNode (pm.PyNode): Node to mirror parenting.
            destNode (pm.PyNode): Optional, supply the destination to mirror to.

        Returns:
            None
        """
        with preservedSelection():
            if not destNode:
                destNode = getMirrorNode(sourceNode)
            if not destNode:
                return

            # get parent of source node
            if self.opts['handleJoints'] and isinstance(sourceNode, pm.nt.Joint):
                srcParent = findMirroredOrCenteredParent(sourceNode, self.opts['axis'])
            else:
                srcParent = sourceNode.getParent()

            if srcParent:
                dstParent = getMirrorNode(srcParent)
                if dstParent:
                    destNode.setParent(dstParent)
                else:
                    destNode.setParent(srcParent)
            else:
                destNode.setParent(None)

            # handle joint reparenting
            if isinstance(destNode, pm.nt.Joint):
                p = destNode.getParent()
                if p and isinstance(p, pm.nt.Joint):
                    if not pm.isConnected(p.scale, destNode.inverseScale):
                        p.scale >> destNode.inverseScale
 def pop_namespace_materials(self):
     """ Connect the outColor to the default shader to the surface
     shader.
     """
     shadingGroups = pm.ls(type="shadingEngine")
     for shader in shadingGroups:
         try:
             default_shader = shader.attr("defaultShader")
         except MayaAttributeError:
             continue
         ds_connections = default_shader.listConnections(s=True, d=False)
         ds_is_connected = pm.isConnected(
             ds_connections[0].attr("outColor"),
             shader.attr("surfaceShader")
         )
         if ds_connections and not ds_is_connected:
             ds_connections[0].connectAttr("outColor", shader.attr("surfaceShader"), f=True)
Exemple #14
0
    def test_create_with_meta_parent(self):
        test_character = luna_rig.components.Character.create(
            name="test_character")
        component1 = luna_rig.AnimComponent.create(character=test_character)
        component2 = luna_rig.AnimComponent.create(meta_parent=component1,
                                                   character=test_character)

        self.assertTrue(
            pm.isConnected(component2.pynode.metaParent,
                           component1.pynode.metaChildren[0]))
        self.assertEqual(component2.meta_parent, component1)

        # Save test scene
        pm.renameFile(
            self.get_temp_filename(
                "anim_component_test_create_with_meta_parent.ma"))
        pm.saveFile(f=1)
Exemple #15
0
 def pop_namespace_materials(self):
     """ Connect the outColor to the default shader to the surface
     shader.
     """
     shadingGroups = pm.ls(type="shadingEngine")
     for shader in shadingGroups:
         try:
             default_shader = shader.attr("defaultShader")
         except MayaAttributeError:
             continue
         ds_connections = default_shader.listConnections(s=True, d=False)
         ds_is_connected = pm.isConnected(
             ds_connections[0].attr("outColor"),
             shader.attr("surfaceShader"))
         if ds_connections and not ds_is_connected:
             ds_connections[0].connectAttr("outColor",
                                           shader.attr("surfaceShader"),
                                           f=True)
def reConnectHwTexture( shader ):
    '''뿌얘진 하느뒈어 텍스쳐를 재연결'''
    shader        = pm.PyNode( shader )

    fileNodes     = shader.color.inputs()
    materialInfos = shader.outputs( type='materialInfo')
        
    if materialInfos and fileNodes:
        try:
            # 잠깐 끊었다가 
            if pm.isConnected( fileNodes[0].message, materialInfos[0].texture[0] ):
                pm.disconnectAttr( fileNodes[0].message, materialInfos[0].texture[0] )

            # 다시연결
            pm.connectAttr( fileNodes[0].message, materialInfos[0].texture[0], na=True, f=True )

        except:
            pass
Exemple #17
0
 def push_namespace_materials(self):
     """ Connected the outColor attribute of the namespace
     shaders to the surface shader.
     """
     shadingGroups = pm.ls(type="shadingEngine")
     for shader in shadingGroups:
         try:
             namespace_shader = shader.attr("namespaceShader")
         except MayaAttributeError:
             continue
         ns_connections = namespace_shader.listConnections(s=True, d=False)
         surface_shader = shader.attr('surfaceShader')
         ns_is_connected = pm.isConnected(
             ns_connections[0].attr("outColor"),
             shader.attr("surfaceShader"))
         if ns_connections and not ns_is_connected:
             ns_connections[0].connectAttr("outColor",
                                           shader.attr('surfaceShader'),
                                           f=True)
Exemple #18
0
def connect_construction_history(connector=None, nodes=[]):
    """Retrieve and connect construction history of specified nodes or all.

    @param connector <string> Control which switches ihi attr of connected node
    @param nodes <list> Nodes to connect their isHistoricallyInteresting attr

    @return pyNode of the connector storing the showHistory attribute
    """

    if not nodes:
        selection = pm.ls(sl=True)
        if selection:
            nodes = selection
        else:
            nodes = pm.ls()
        # end if nodes are selected or select all
    else:
        nodes = [pm.PyNode(node) for node in nodes]
    # end if no nodes specified

    if not connector:
        if not pm.objExists('ConstructionHistory'):
            connector = pm.createNode('transform', n='ConstructionHistory')
        else:
            connector = pm.PyNode('ConstructionHistory')
        # end if create ConstructionHistory
    else:
        connector = pm.PyNode(connector)
    # end if create connector pyNode

    if not pm.objExists('%s.showHistory' % connector):
        connector.addAttr('showHistory', at='short', min=0, max=1)
        connector.showHistory.set(e=True, cb=True)
    # end if create attribute

    for node in nodes:
        if not pm.isConnected(connector.showHistory, node.ihi):
            connector.showHistory >> node.ihi
        # end if no connection has been done
    # end for connect attributes

    return connector
Exemple #19
0
def connect_construction_history(connector=None, nodes=[]):
    """Retrieve and connect construction history of specified nodes or all.

    @param connector <string> Control which switches ihi attr of connected node
    @param nodes <list> Nodes to connect their isHistoricallyInteresting attr

    @return pyNode of the connector storing the showHistory attribute
    """

    if not nodes:
        selection = pm.ls(sl=True)
        if selection:
            nodes = selection
        else:
            nodes = pm.ls()
        # end if nodes are selected or select all
    else:
        nodes = [pm.PyNode(node) for node in nodes]
    # end if no nodes specified

    if not connector:
        if not pm.objExists('ConstructionHistory'):
            connector = pm.createNode('transform', n='ConstructionHistory')
        else:
            connector = pm.PyNode('ConstructionHistory')
        # end if create ConstructionHistory
    else:
        connector = pm.PyNode(connector)
    # end if create connector pyNode

    if not pm.objExists('%s.showHistory' % connector):
        connector.addAttr('showHistory', at='short', min=0, max=1)
        connector.showHistory.set(e=True, cb=True)
    # end if create attribute

    for node in nodes:
        if not pm.isConnected(connector.showHistory, node.ihi):
            connector.showHistory >> node.ihi
        # end if no connection has been done
    # end for connect attributes

    return connector
 def push_namespace_materials(self):
     """ Connected the outColor attribute of the namespace
     shaders to the surface shader.
     """
     shadingGroups = pm.ls(type="shadingEngine")
     for shader in shadingGroups:
         try:
             namespace_shader = shader.attr("namespaceShader")
         except MayaAttributeError:
             continue
         ns_connections = namespace_shader.listConnections(s=True, d=False)
         surface_shader = shader.attr('surfaceShader')
         ns_is_connected = pm.isConnected(
             ns_connections[0].attr("outColor"),
             shader.attr("surfaceShader")
         )
         if ns_connections and not ns_is_connected:
             ns_connections[0].connectAttr(
                 "outColor",
                 shader.attr('surfaceShader'),
                 f=True
             )
def connectJawTransRot(faceScene=None, jawDict=None):
    #set default
    if jawDict:
        pm.setAttr(faceScene + ".jawOpenRemap", jawDict["jawOpen"], keyable=True)
        pm.setAttr(faceScene + ".jawCloseRemap", jawDict["jawClose"], keyable=True)
        pm.setAttr(faceScene + ".jawRightRemap", jawDict["jawRight"], keyable=True)
        pm.setAttr(faceScene + ".jawLeftRemap", jawDict["jawLeft"], keyable=True)
        pm.setAttr(faceScene + ".jawForwardRemap", jawDict["jawForward"], keyable=True)
        pm.setAttr(faceScene + ".jawBackRemap", jawDict["jawBack"], keyable=True)
        pm.setAttr(faceScene + ".jawUpRemap", jawDict["jawUp"], keyable=True)
        pm.setAttr(faceScene + ".jawDownRemap", jawDict["jawDown"], keyable=True)
    else:
        pm.setAttr(faceScene + ".jawOpenRemap", -20, keyable=True)
        pm.setAttr(faceScene + ".jawCloseRemap", 5, keyable=True)
        pm.setAttr(faceScene + ".jawRightRemap", 1, keyable=True)
        pm.setAttr(faceScene + ".jawLeftRemap", -1, keyable=True)
        pm.setAttr(faceScene + ".jawForwardRemap", 2, keyable=True)
        pm.setAttr(faceScene + ".jawBackRemap", -2, keyable=True)
        pm.setAttr(faceScene + ".jawUpRemap", 1, keyable=True)
        pm.setAttr(faceScene + ".jawDownRemap", -1, keyable=True)

    #connect jaw rotate
    if pm.objExists('jawDownBlendRC'):
        if not pm.isConnected(faceScene + ".jawOpenRemap", "jawDownBlendRC.red[1].red_Position"):
            pm.connectAttr(faceScene + ".jawOpenRemap", "jawDownBlendRC.red[1].red_Position")
        if not pm.isConnected(faceScene + ".jawCloseRemap", "jawDownBlendRC.green[1].green_Position"):
            pm.connectAttr(faceScene + ".jawCloseRemap", "jawDownBlendRC.green[1].green_Position")
    else:
        pm.warning('jawDownBlendRC Remap does not exist.')
        #create transX system
    if pm.objExists('jawTranslateLeftRightRC'):
        if not pm.isConnected(faceScene + ".jawRightRemap", "jawTranslateLeftRightRC.red[1].red_Position"):
            pm.connectAttr(faceScene + ".jawRightRemap", "jawTranslateLeftRightRC.red[1].red_Position")
        if not pm.isConnected(faceScene + ".jawLeftRemap", "jawTranslateLeftRightRC.green[1].green_Position"):
            pm.connectAttr(faceScene + ".jawLeftRemap", "jawTranslateLeftRightRC.green[1].green_Position")
    else:
        pm.warning('jawTranslateLeftRightRC Remap does not exist')
        #create transY system
    if pm.objExists('jawTranslateForwardBackRC'):
        if not pm.isConnected(faceScene + ".jawForwardRemap", "jawTranslateForwardBackRC.red[1].red_Position"):
            pm.connectAttr(faceScene + ".jawForwardRemap", "jawTranslateForwardBackRC.red[1].red_Position")
        if not pm.isConnected(faceScene + ".jawBackRemap", "jawTranslateForwardBackRC.green[1].green_Position"):
            pm.connectAttr(faceScene + ".jawBackRemap", "jawTranslateForwardBackRC.green[1].green_Position")
    else:
        pm.warning('jawTranslateForwardBackRC Remap does not exist')
Exemple #22
0
def setRetarget(node=None, target=None):
    """
    Sets the given nodes retarget to the given target node.
    
    Args:
        node(PyNode): A node to set the retarget of.
        target(PyNode): The target node, if None this will disconnect any existing connections..
    """
    selection = pmc.selected()
    node = node or selection[0]
    if target is None:
        if len(selection) > 1:
            target = selection[1]

    # Add and connect the retarget
    if not node.hasAttr(RETARGET_ATTR_NAME):
        node.addAttr(RETARGET_ATTR_NAME, at='message')
    if target:
        if not pmc.isConnected(target.message, node.attr(RETARGET_ATTR_NAME)):
            target.message.connect(node.attr(RETARGET_ATTR_NAME), force=True)
    else:
        node.attr(RETARGET_ATTR_NAME).disconnect()
    pmc.displayInfo('Defined retarget from %s to %s' % (target, node))
Exemple #23
0
    def test_createDriveControls(self):
        fr = FollowRibbon.FollowRibbon(name='blah')
        plane = pm.nurbsPlane(axis=[0, 1, 0],
                              patchesU=8,
                              patchesV=1,
                              lengthRatio=.1,
                              ch=0)[0]
        grps, jnts, cposNodes = fr._createPlaneControls(plane=plane,
                                                        direction='u',
                                                        number=4)

        mainGrp, ctrls = fr._createDriveControls(grps=grps,
                                                 cposNodes=cposNodes)

        self.assertEqual(mainGrp, 'blah_ctrlsGrp')
        self.testLib.assertListEqual(
            ctrls,
            ['blah_ctrl_01', 'blah_ctrl_02', 'blah_ctrl_03', 'blah_ctrl_04'])

        for index in range(4):
            self.assertTrue(
                pm.objExists('blah_ctrlTopGrp_%s' % str(index + 1).zfill(2)))
            self.assertTrue(
                pm.objExists('blah_ctrlMidGrp_%s' % str(index + 1).zfill(2)))
            self.assertTrue(
                pm.objExists('blah_ctrlBtmGrp_%s' % str(index + 1).zfill(2)))
            self.assertTrue(
                pm.objExists('blah_InvertMdNode_%s' % str(index + 1).zfill(2)))
            self.assertTrue(
                pm.objExists('blah_ctrl_%s' % str(index + 1).zfill(2)))

            self.assertEqual(
                pm.listRelatives('blah_ctrlTopGrp_%s' %
                                 str(index + 1).zfill(2),
                                 parent=1)[0].name(), 'blah_ctrlsGrp')

            self.testLib.assertConstrained(grps[index].name(),
                                           'blah_ctrlTopGrp_%s' %
                                           str(index + 1).zfill(2),
                                           type='parent')

            self.assertTrue(
                pm.isConnected(
                    'blah_ctrl_%s.translate' % str(index + 1).zfill(2),
                    'blah_InvertMdNode_%s.input1' % str(index + 1).zfill(2)))
            self.assertTrue(
                pm.isConnected(
                    'blah_InvertMdNode_%s.output' % str(index + 1).zfill(2),
                    'blah_ctrlBtmGrp_%s.translate' % str(index + 1).zfill(2)))

            self.assertTrue(
                pm.objExists('blah_ctrl_%s.uParam' % str(index + 1).zfill(2)))
            self.assertTrue(
                pm.objExists('blah_ctrl_%s.vParam' % str(index + 1).zfill(2)))

            self.assertTrue(
                pm.isConnected(
                    'blah_ctrl_%s.uParam' % str(index + 1).zfill(2),
                    'blah_drvCPOS_%s.parameterU' % str(index + 1).zfill(2)))
            self.assertTrue(
                pm.isConnected(
                    'blah_ctrl_%s.vParam' % str(index + 1).zfill(2),
                    'blah_drvCPOS_%s.parameterV' % str(index + 1).zfill(2)))
Exemple #24
0
    def test_createPlaneControls(self):
        fr = FollowRibbon.FollowRibbon(name='blah')
        plane = pm.nurbsPlane(axis=[0, 1, 0],
                              patchesU=8,
                              patchesV=1,
                              lengthRatio=.1,
                              ch=0)[0]

        grps, jnts, cposNodes = fr._createPlaneControls(plane=plane,
                                                        direction='u',
                                                        number=6)

        self.testLib.assertListEqual(cposNodes, [
            'blah_drvCPOS_01', 'blah_drvCPOS_02', 'blah_drvCPOS_03',
            'blah_drvCPOS_04', 'blah_drvCPOS_05', 'blah_drvCPOS_06'
        ])

        self.assertEqual(grps[0].name(), 'blah_drvGrp_01')
        self.assertEqual(grps[1].name(), 'blah_drvGrp_02')
        self.assertEqual(grps[2].name(), 'blah_drvGrp_03')
        self.assertEqual(grps[3].name(), 'blah_drvGrp_04')
        self.assertEqual(grps[4].name(), 'blah_drvGrp_05')
        self.assertEqual(grps[5].name(), 'blah_drvGrp_06')

        self.assertEqual(jnts[0].name(), 'blah_drvJnt_01')
        self.assertEqual(jnts[1].name(), 'blah_drvJnt_02')
        self.assertEqual(jnts[2].name(), 'blah_drvJnt_03')
        self.assertEqual(jnts[3].name(), 'blah_drvJnt_04')
        self.assertEqual(jnts[4].name(), 'blah_drvJnt_05')
        self.assertEqual(jnts[5].name(), 'blah_drvJnt_06')

        self.assertTrue(pm.objExists('blah_drvCPOS_01'))
        self.assertTrue(pm.objExists('blah_drvCPOS_02'))
        self.assertTrue(pm.objExists('blah_drvCPOS_03'))
        self.assertTrue(pm.objExists('blah_drvCPOS_04'))
        self.assertTrue(pm.objExists('blah_drvCPOS_05'))
        self.assertTrue(pm.objExists('blah_drvCPOS_06'))

        self.assertEqual(pm.getAttr('blah_drvCPOS_01.turnOnPercentage'), 1)

        self.assertEqual(pm.getAttr('blah_drvCPOS_01.parameterV'), .5)
        self.assertEqual(pm.getAttr('blah_drvCPOS_02.parameterV'), .5)
        self.assertEqual(pm.getAttr('blah_drvCPOS_03.parameterV'), .5)
        self.assertEqual(pm.getAttr('blah_drvCPOS_04.parameterV'), .5)
        self.assertEqual(pm.getAttr('blah_drvCPOS_05.parameterV'), .5)
        self.assertEqual(pm.getAttr('blah_drvCPOS_06.parameterV'), .5)

        self.assertAlmostEquals(pm.getAttr('blah_drvCPOS_01.parameterU'), 0)
        self.assertAlmostEquals(pm.getAttr('blah_drvCPOS_02.parameterU'), .2,
                                2)
        self.assertAlmostEquals(pm.getAttr('blah_drvCPOS_03.parameterU'), .4,
                                2)
        self.assertAlmostEquals(pm.getAttr('blah_drvCPOS_04.parameterU'), .6,
                                2)
        self.assertAlmostEquals(pm.getAttr('blah_drvCPOS_05.parameterU'), .8,
                                2)
        self.assertAlmostEquals(pm.getAttr('blah_drvCPOS_06.parameterU'), 1)

        self.assertTrue(pm.objExists('blah_drvGrp_01'))
        self.assertTrue(pm.objExists('blah_drvGrp_02'))
        self.assertTrue(pm.objExists('blah_drvGrp_03'))
        self.assertTrue(pm.objExists('blah_drvGrp_04'))
        self.assertTrue(pm.objExists('blah_drvGrp_05'))
        self.assertTrue(pm.objExists('blah_drvGrp_06'))

        self.assertTrue(
            pm.isConnected('blah_drvCPOS_01.position',
                           'blah_drvGrp_01.translate'))
        self.assertTrue(
            pm.isConnected('blah_drvCPOS_02.position',
                           'blah_drvGrp_02.translate'))
        self.assertTrue(
            pm.isConnected('blah_drvCPOS_03.position',
                           'blah_drvGrp_03.translate'))
        self.assertTrue(
            pm.isConnected('blah_drvCPOS_04.position',
                           'blah_drvGrp_04.translate'))
        self.assertTrue(
            pm.isConnected('blah_drvCPOS_05.position',
                           'blah_drvGrp_05.translate'))
        self.assertTrue(
            pm.isConnected('blah_drvCPOS_06.position',
                           'blah_drvGrp_06.translate'))

        self.assertTrue(pm.objExists('blah_drvJnt_01'))
        self.assertTrue(pm.objExists('blah_drvJnt_02'))
        self.assertTrue(pm.objExists('blah_drvJnt_03'))
        self.assertTrue(pm.objExists('blah_drvJnt_04'))
        self.assertTrue(pm.objExists('blah_drvJnt_05'))
        self.assertTrue(pm.objExists('blah_drvJnt_06'))

        self.assertEqual(
            pm.listRelatives('blah_drvJnt_01', parent=1)[0], 'blah_drvGrp_01')
        self.assertEqual(
            pm.listRelatives('blah_drvJnt_02', parent=1)[0], 'blah_drvGrp_02')
        self.assertEqual(
            pm.listRelatives('blah_drvJnt_03', parent=1)[0], 'blah_drvGrp_03')
        self.assertEqual(
            pm.listRelatives('blah_drvJnt_04', parent=1)[0], 'blah_drvGrp_04')
        self.assertEqual(
            pm.listRelatives('blah_drvJnt_05', parent=1)[0], 'blah_drvGrp_05')
        self.assertEqual(
            pm.listRelatives('blah_drvJnt_06', parent=1)[0], 'blah_drvGrp_06')
Exemple #25
0
    def test_create_default(self):
        test_character = luna_rig.components.Character.create(
            name="test_character")
        new_component = luna_rig.AnimComponent.create(character=test_character)

        # Assertions
        # Metanode
        self.assertEqual(
            str(new_component.pynode),
            "{0}_{1}_00_meta".format(new_component.side, new_component.name))
        self.assertEqual(new_component.pynode.metaType.get(),
                         luna_rig.AnimComponent.as_str())
        self.assertEqual(
            str(new_component.root),
            "{0}_{1}_00_comp".format(new_component.side, new_component.name))
        self.assertEqual(
            str(new_component.group_ctls),
            "{0}_{1}_00_ctls".format(new_component.side, new_component.name))
        self.assertEqual(
            str(new_component.group_joints),
            "{0}_{1}_00_jnts".format(new_component.side, new_component.name))
        self.assertEqual(
            str(new_component.group_parts),
            "{0}_{1}_00_parts".format(new_component.side, new_component.name))
        self.assertEqual(
            str(new_component.group_noscale),
            "{0}_{1}_00_noscale".format(new_component.side,
                                        new_component.name))
        self.assertEqual(
            str(new_component.group_out),
            "{0}_{1}_00_out".format(new_component.side, new_component.name))
        self.assertEqual(new_component.tag, "")

        # Character connection
        self.assertEqual(new_component.character, test_character)

        # Meta parent attrs on hierarchy
        self.assertTrue(pm.hasAttr(new_component.root, "metaParent"))
        self.assertTrue(pm.hasAttr(new_component.group_ctls, "metaParent"))
        self.assertTrue(pm.hasAttr(new_component.group_joints, "metaParent"))
        self.assertTrue(pm.hasAttr(new_component.group_parts, "metaParent"))
        self.assertTrue(pm.hasAttr(new_component.group_out, "metaParent"))
        self.assertTrue(pm.hasAttr(new_component.group_noscale, "metaParent"))

        # Attributes on meta node
        self.assertTrue(pm.hasAttr(new_component.pynode, "rootGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "ctlsGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "jointsGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "partsGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "noScaleGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "outGroup"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "outHooks"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "inHook"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "bindJoints"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "ctlChain"))
        self.assertTrue(pm.hasAttr(new_component.pynode, "controls"))

        # Connections to metanode
        self.assertTrue(
            pm.isConnected(new_component.root.metaParent,
                           new_component.pynode.rootGroup))
        self.assertTrue(
            pm.isConnected(new_component.group_ctls.metaParent,
                           new_component.pynode.ctlsGroup))
        self.assertTrue(
            pm.isConnected(new_component.group_joints.metaParent,
                           new_component.pynode.jointsGroup))
        self.assertTrue(
            pm.isConnected(new_component.group_parts.metaParent,
                           new_component.pynode.partsGroup))
        self.assertTrue(
            pm.isConnected(new_component.group_out.metaParent,
                           new_component.pynode.outGroup))
        self.assertTrue(
            pm.isConnected(new_component.group_noscale.metaParent,
                           new_component.pynode.noScaleGroup))

        # Name, side
        self.assertEqual(new_component.name, "anim_component")
        self.assertEqual(new_component.side, "c")

        # Save test scene
        pm.renameFile(
            self.get_temp_filename("anim_component_test_create_default.ma"))
        pm.saveFile(f=1)
Exemple #26
0
    def apply_cv_bs_btnCmd(self):
        # INFO from GUI

        pm.undoInfo(openChunk=True)

        lower_val = self.lower_val_spinBox.value()
        upper_val = self.upper_val_spinBox.value()
        bs_method = self.bs_method_comboBox.currentText()

        if upper_val > lower_val:
            direction = 1
        elif lower_val > upper_val:
            direction = -1
        else:
            direction = 0  # full blendshape

        selection_list = pm.ls(sl=True)

        if selection_list:
            if len(selection_list) != 2:  # invalid selection
                if len(selection_list) > 2:
                    pm.warning(
                        '... More than 2 obj(s) were selected, operation was not initiated.'
                    )
                else:
                    pm.warning(
                        '... Less than 2 obj(s) were selected, operation was not initiated'
                    )
            else:  # continue

                driver_tfm = selection_list[0]
                driven_tfm = selection_list[1]

                driver_name = driver_tfm.stripNamespace()

                driver_crv_shape_list = pm.listRelatives(driver_tfm,
                                                         ad=True,
                                                         type='nurbsCurve')
                driver_crv_list = list(
                    set(pm.listRelatives(driver_crv_shape_list, parent=True)))

                driven_curve_shape_list = pm.listRelatives(driven_tfm,
                                                           ad=True,
                                                           type='nurbsCurve')
                driven_crv_list = list(
                    set(pm.listRelatives(driven_curve_shape_list,
                                         parent=True)))

                if bs_method == 'Name Order':
                    driver_crv_list = self.natural_sort(driver_crv_list)
                    driven_crv_list = self.natural_sort(driven_crv_list)

                elif bs_method == 'Root Distance':
                    curve_pair_list = self.get_closest_crv_pair_list(
                        driver_crv_list, driven_crv_list)

                if not driven_tfm.hasAttr('_cv_bsn_'):
                    pm.addAttr(driven_tfm, ln='_cv_bsn_', at='double', k=True)
                    driven_tfm._cv_bsn_.lock()

                if not driven_tfm.hasAttr('cv_bsn_src'):
                    pm.addAttr(driven_tfm,
                               ln='cv_bsn_src',
                               dataType='string',
                               keyable=True)
                driven_tfm.cv_bsn_src.unlock()
                driven_tfm.cv_bsn_src.set(driver_tfm.fullPath())
                driven_tfm.cv_bsn_src.lock()

                if not driven_tfm.hasAttr('cv_bsn_en'):
                    pm.addAttr(driven_tfm,
                               ln='cv_bsn_en',
                               at='double',
                               k=True,
                               min=0,
                               max=1,
                               dv=1)

                if bs_method == 'Name Order':

                    for driver, driven in zip(driver_crv_list,
                                              driven_crv_list):
                        blendshape = self.cv_blendshape(driver=driver,
                                                        driven=driven,
                                                        lower_val=lower_val,
                                                        upper_val=upper_val,
                                                        direction=direction)
                        if not pm.isConnected(driven_tfm.cv_bsn_en,
                                              blendshape.en):
                            driven_tfm.cv_bsn_en >> blendshape.en

                elif bs_method == 'Root Distance':

                    for pair in curve_pair_list:
                        driver, driven = pair
                        blendshape = self.cv_blendshape(driver=driver,
                                                        driven=driven,
                                                        lower_val=lower_val,
                                                        upper_val=upper_val,
                                                        direction=direction)
                        if not pm.isConnected(driven_tfm.cv_bsn_en,
                                              blendshape.en):
                            driven_tfm.cv_bsn_en >> blendshape.en

        pm.undoInfo(closeChunk=True)
    def test_createPlaneControls(self):
        fr = FollowRibbon.FollowRibbon(name="blah")
        plane = pm.nurbsPlane(axis=[0, 1, 0], patchesU=8, patchesV=1, lengthRatio=0.1, ch=0)[0]

        grps, jnts, cposNodes = fr._createPlaneControls(plane=plane, direction="u", number=6)

        self.testLib.assertListEqual(
            cposNodes,
            [
                "blah_drvCPOS_01",
                "blah_drvCPOS_02",
                "blah_drvCPOS_03",
                "blah_drvCPOS_04",
                "blah_drvCPOS_05",
                "blah_drvCPOS_06",
            ],
        )

        self.assertEqual(grps[0].name(), "blah_drvGrp_01")
        self.assertEqual(grps[1].name(), "blah_drvGrp_02")
        self.assertEqual(grps[2].name(), "blah_drvGrp_03")
        self.assertEqual(grps[3].name(), "blah_drvGrp_04")
        self.assertEqual(grps[4].name(), "blah_drvGrp_05")
        self.assertEqual(grps[5].name(), "blah_drvGrp_06")

        self.assertEqual(jnts[0].name(), "blah_drvJnt_01")
        self.assertEqual(jnts[1].name(), "blah_drvJnt_02")
        self.assertEqual(jnts[2].name(), "blah_drvJnt_03")
        self.assertEqual(jnts[3].name(), "blah_drvJnt_04")
        self.assertEqual(jnts[4].name(), "blah_drvJnt_05")
        self.assertEqual(jnts[5].name(), "blah_drvJnt_06")

        self.assertTrue(pm.objExists("blah_drvCPOS_01"))
        self.assertTrue(pm.objExists("blah_drvCPOS_02"))
        self.assertTrue(pm.objExists("blah_drvCPOS_03"))
        self.assertTrue(pm.objExists("blah_drvCPOS_04"))
        self.assertTrue(pm.objExists("blah_drvCPOS_05"))
        self.assertTrue(pm.objExists("blah_drvCPOS_06"))

        self.assertEqual(pm.getAttr("blah_drvCPOS_01.turnOnPercentage"), 1)

        self.assertEqual(pm.getAttr("blah_drvCPOS_01.parameterV"), 0.5)
        self.assertEqual(pm.getAttr("blah_drvCPOS_02.parameterV"), 0.5)
        self.assertEqual(pm.getAttr("blah_drvCPOS_03.parameterV"), 0.5)
        self.assertEqual(pm.getAttr("blah_drvCPOS_04.parameterV"), 0.5)
        self.assertEqual(pm.getAttr("blah_drvCPOS_05.parameterV"), 0.5)
        self.assertEqual(pm.getAttr("blah_drvCPOS_06.parameterV"), 0.5)

        self.assertAlmostEquals(pm.getAttr("blah_drvCPOS_01.parameterU"), 0)
        self.assertAlmostEquals(pm.getAttr("blah_drvCPOS_02.parameterU"), 0.2, 2)
        self.assertAlmostEquals(pm.getAttr("blah_drvCPOS_03.parameterU"), 0.4, 2)
        self.assertAlmostEquals(pm.getAttr("blah_drvCPOS_04.parameterU"), 0.6, 2)
        self.assertAlmostEquals(pm.getAttr("blah_drvCPOS_05.parameterU"), 0.8, 2)
        self.assertAlmostEquals(pm.getAttr("blah_drvCPOS_06.parameterU"), 1)

        self.assertTrue(pm.objExists("blah_drvGrp_01"))
        self.assertTrue(pm.objExists("blah_drvGrp_02"))
        self.assertTrue(pm.objExists("blah_drvGrp_03"))
        self.assertTrue(pm.objExists("blah_drvGrp_04"))
        self.assertTrue(pm.objExists("blah_drvGrp_05"))
        self.assertTrue(pm.objExists("blah_drvGrp_06"))

        self.assertTrue(pm.isConnected("blah_drvCPOS_01.position", "blah_drvGrp_01.translate"))
        self.assertTrue(pm.isConnected("blah_drvCPOS_02.position", "blah_drvGrp_02.translate"))
        self.assertTrue(pm.isConnected("blah_drvCPOS_03.position", "blah_drvGrp_03.translate"))
        self.assertTrue(pm.isConnected("blah_drvCPOS_04.position", "blah_drvGrp_04.translate"))
        self.assertTrue(pm.isConnected("blah_drvCPOS_05.position", "blah_drvGrp_05.translate"))
        self.assertTrue(pm.isConnected("blah_drvCPOS_06.position", "blah_drvGrp_06.translate"))

        self.assertTrue(pm.objExists("blah_drvJnt_01"))
        self.assertTrue(pm.objExists("blah_drvJnt_02"))
        self.assertTrue(pm.objExists("blah_drvJnt_03"))
        self.assertTrue(pm.objExists("blah_drvJnt_04"))
        self.assertTrue(pm.objExists("blah_drvJnt_05"))
        self.assertTrue(pm.objExists("blah_drvJnt_06"))

        self.assertEqual(pm.listRelatives("blah_drvJnt_01", parent=1)[0], "blah_drvGrp_01")
        self.assertEqual(pm.listRelatives("blah_drvJnt_02", parent=1)[0], "blah_drvGrp_02")
        self.assertEqual(pm.listRelatives("blah_drvJnt_03", parent=1)[0], "blah_drvGrp_03")
        self.assertEqual(pm.listRelatives("blah_drvJnt_04", parent=1)[0], "blah_drvGrp_04")
        self.assertEqual(pm.listRelatives("blah_drvJnt_05", parent=1)[0], "blah_drvGrp_05")
        self.assertEqual(pm.listRelatives("blah_drvJnt_06", parent=1)[0], "blah_drvGrp_06")
Exemple #28
0
for source, target, w, type in constraints:
    for side, chan in [("_l_", "x"), ("_r_", "y")]:
        src = source.replace("_s_", side)
        tgt = target.replace("_s_", side)
        fkik = attrRef.replace("_s_", side)
        fkik = pym.PyNode(fkik).attr("FKIK")
        ikfk = pym.PyNode("IKFK").attr("output2D" + chan)
        fC = getattr(pym, type)
        mFC = getattr(mc, type)
        tl = mFC(tgt, q=True, tl=True)
        wal = mFC(tgt, q=True, wal=True)
        dW = dict(zip(tl, wal))
        oC = mFC(tgt, q=True, n=True)
        if w == "IKFK":
            print "connect:", ikfk, "to:", dW[src]
            if not pym.isConnected(ikfk, ".".join([oC, dW[src]])):
                print "New"
                pym.connectAttr(ikfk, ".".join([oC, dW[src]]))
        elif w == "FKIK":
            print "connect:", fkik, "to:", dW[src]
            if not pym.isConnected(fkik, ".".join([oC, dW[src]])):
                print "New"
                pym.connectAttr(fkik, ".".join([oC, dW[src]]))

""" Vis connections """
conns = [
    ("FKIK", "foot_s_ik_control_shp.visibility"),
    ("FKIK", "polevectorLeg_s_control_shp.visibility"),
    ("IKFK", "foot_s_fk_control_shp.visibility"),
    ("IKFK", "lowerleg_s_fk_control_shp.visibility"),
    ("IKFK", "upperleg_s_fk_control_shp.visibility")
Exemple #29
0
def getDeformerSet(deformerNode):
    possibleDeformerSets = deformerNode.message.outputs()
    for each in possibleDeformerSets:
        if pymel.nodeType(each) == 'objectSet':
            if pymel.isConnected(deformerNode.message, each.usedBy[0]):
                return each