예제 #1
0
def rtb_remove(highresListDropdown, *args, **kwargs):
  ''' remove item from the list and delete live-mesh and groups '''
  global defaultString
  high = highresListDropdown.getValue()

  if not high == defaultString:
    high = pm.PyNode(high.split("'")[0]) #get rid of unicode crap
    high.rename(high.rstrip('_high'))
    pm.parent(high, world=True)

    high.setScale([1,1,1])
    pm.disconnectAttr('persp.translate', high.scalePivot)

    if pm.displaySurface(high, query=True, xRay=True)[0] == True:
      pm.displaySurface(high, xRay=False)
    if not high.visibility.get():
      high.visibility.set(True)

    highShape = high.getShape()
    highShape.overrideDisplayType.set(0) #sets to normal mode
    highShape.overrideEnabled.set(0) #disable display overrides

    pm.delete(str(high)+'_RETOPO')

  rtb_highres_list_populate(highresListDropdown)
예제 #2
0
 def setToCurve(target, objectData, position=0):
     #pathAnimationを指定.fractionMode=Trueにすることで0~1にu値を正規化
     motionPathName=pm.pathAnimation(objectData, curve=target, fractionMode=True)
     #文字列をstr型で使いたいためAsciiコードに変換
     ascPathName = motionPathName.encode('ascii')
     pm.setAttr(ascPathName+".uValue", position)
     pm.disconnectAttr(ascPathName+".uValue")
예제 #3
0
def disconnectShaders(objArray=None):
    if objArray is None: objArray = pm.ls(sl=1)
    shapeNodes = []
    #for all selected obj
    for obj in objArray:
        #selection is mesh
        if pm.ls(obj, type='mesh'):
            shapeNodes.append(obj)
        #selection is not mesh. search hierarchy
        else:
            shapeNodes = shapeNodes + (pm.ls(obj, dag=1, ap=1, type='mesh'))
        if shapeNodes == []:
            print 'Warning: Select either mesh or transform nodes with valid shapes. %s' % (
                obj)
            #return False
        print shapeNodes
        #for all shape nodes
        for shapeNode in shapeNodes:
            conns = pm.listConnections(shapeNode)
            plugs = pm.listConnections(shapeNode,
                                       type='shadingEngine',
                                       connections=True)
            for conn in conns:
                if conn.type() == 'shadingEngine':
                    print 'Disconnecting shader engine: %s >>> %s' % (obj,
                                                                      conn)
                    #break ocnnection to shader
                    pm.disconnectAttr(plugs[0])
예제 #4
0
def CleanUpMod(asset):
    pm.select(asset)
    mel.eval('SelectHierarchy;')
    for i in pm.ls(sl=1, type='mesh'):
        for j in pm.listConnections(i, c=1, p=1, s=1):
            try:
                pm.disconnectAttr(j[0], j[1])
            except:
                pass
            try:
                pm.disconnectAttr(j[1], j[0])
            except:
                pass
    for i in pm.ls(sl=1, type='transform'):
        mel.eval('CenterPivot')
    pm.hyperShade(assign='initialParticleSE')

    unknown_plugins = pm.unknownPlugin(q=True, list=True)
    if unknown_plugins:
        for p in unknown_plugins:
            try:
                pm.unknownPlugin(p, r=True)
                print 'remove', p
            except:
                pass
    print 'Clean Done'
예제 #5
0
def oriCns(driver, driven, maintainOffset=False):
    """
    Apply orientation constraint changing XYZ  default connexions by rotate compound connexions

    Note:
        We have found an evaluation difference in the values if the connexion is compound or by axis

    Args:
        driver (dagNode or dagNode list): Driver object.
        driven (dagNode): Driven object.
        maintainOffset (bool): Keep the offset.

    Returns:
        pyNode: Orientation constraintn node.

    Example:
        .. code-block:: python

            import mgear.maya.applyop as aop
            import pymel.core as pm
            sphere = pm.polySphere(n='sphereDriver')
            cube = pm.polyCube(n='cubeDriven')
            ori_cns = aop.oriCns(sphere[0], cube[0], True)

    """
    oriCns = pm.orientConstraint(driver, driven, maintainOffset=maintainOffset)
    for axis in "XYZ":
        pm.disconnectAttr(oriCns + ".constraintRotate" + axis,
                          driven + ".rotate" + axis)
    pm.connectAttr(oriCns + ".constraintRotate", driven + ".rotate", f=True)

    return oriCns
예제 #6
0
파일: utils.py 프로젝트: rusn07/mgear
def clearSprings(model):
    """Delete baked animation from spring

    Args:
        model (dagNode): The rig top node
    """
    springNodes = getControlers(model, gSuffix=PLOT_GRP_SUFFIX)
    pairblends = [
        sn.listConnections(type="pairBlend")[0] for sn in springNodes
    ]

    for pb in pairblends:
        animCrvs = pb.listConnections(type="animCurveTA")
        for fcrv in animCrvs:
            for conn in fcrv.listConnections(connections=True,
                                             destination=True,
                                             plugs=True):

                pm.disconnectAttr(conn[0], conn[1])
        # reset the value to 0
        attrs = ["inRotateX1", "inRotateY1", "inRotateZ1"]
        for attr in attrs:
            pb.attr(attr).set(0)

        # delete fcurves
        pm.delete(animCrvs)
예제 #7
0
def parentConnect(parent=None, child=None):
    '''
    Specific method for connecting parent / child relationships in a metarig
    '''
    # Validation
    if not parent or not child and (len(pmc.selected()) == 2):
        parent = pmc.selected()[0]
        child = pmc.selected()[1]

    if not parent or not child:
        return 'Argument Error, Please supply a parent and child node'

    if parent in getAllMetaChildren(child):
        return '%s is a meta descendent of %s and cannot also be its parent' % (parent, child)

    # Disconnect from old parent's children array
    oldParent = pmc.listConnections('%s.metaParent' % child)

    if type(oldParent) == type([]):
        metaChildren = getMetaChildren(oldParent[0])
        childIndex = metaChildren.index(child)
        pmc.disconnectAttr('%s.message' % child, '%s.metaChildren[%s]' % (oldParent[0], childIndex))
    # Connect to new parent's children array
    metaChildren = getMetaChildren(parent)
    pmc.connectAttr('%s.message' % child, '%s.metaChildren[%s]' % (parent, len(metaChildren)))

    # Connect new parent
    messageConnect(fromNode=parent, toNode=child, fromName='message', toName='metaParent')
def rtb_remove(highresListDropdown, *args, **kwargs):
    ''' remove item from the list and delete live-mesh and groups '''
    global defaultString
    high = highresListDropdown.getValue()

    if not high == defaultString:
        high = pm.PyNode(high.split("'")[0])  #get rid of unicode crap
        high.rename(high.rstrip('_high'))
        pm.parent(high, world=True)

        high.setScale([1, 1, 1])
        pm.disconnectAttr('persp.translate', high.scalePivot)

        if pm.displaySurface(high, query=True, xRay=True)[0] == True:
            pm.displaySurface(high, xRay=False)
        if not high.visibility.get():
            high.visibility.set(True)

        highShape = high.getShape()
        highShape.overrideDisplayType.set(0)  #sets to normal mode
        highShape.overrideEnabled.set(0)  #disable display overrides

        pm.delete(str(high) + '_RETOPO')

    rtb_highres_list_populate(highresListDropdown)
예제 #9
0
def DeleteConnections(node):

    for conn in node.listConnections(plugs=True, connections=True):
        try:
            pm.disconnectAttr(conn[0])
        except:
            pass
예제 #10
0
def jointsOnCurve(crv=None, num=None, name=None):
    if not crv: return
    if not num: return
    if not name: return
    if num < 1: return

    param_increment = 1.0/float(num)
    param = 0
    curveShape = pm.PyNode(crv).getShape()
    prnt = []
    for i in range(num):
        pm.select(clear=1)
        # Create joint
        jnt = pm.joint(n=name+'_'+str(i).zfill(2))
        # Attach to curve
        poci = pm.createNode('pointOnCurveInfo')
        pm.connectAttr('%s.ws'%curveShape,'%s.inputCurve'%poci,f=1)
        pm.connectAttr('%s.position'%poci,'%s.translate'%jnt,f=1)
        pm.setAttr('%s.parameter'%poci,param)
        pm.setAttr('%s.turnOnPercentage'%poci,1)

        pm.disconnectAttr('%s.position'%poci,'%s.translate'%jnt)
        pm.delete(poci)

        if len(prnt):
            pm.parent(jnt,prnt[-1])

        prnt.append(jnt)
        param += param_increment
예제 #11
0
def sanitizeMultiMessageAttribute(attribute):
    """Consolidate all connections to the given attribute to sequential indices from 0."""
    connections = attribute.listConnections(connections=True, plugs=True)
    for index, connection in enumerate(connections):
        thisPlug, incomingPlug = connection
        pm.disconnectAttr(incomingPlug, thisPlug)
        pm.connectAttr(incomingPlug, attribute[index])
예제 #12
0
    def addOperatorsIkTwist(self):

        for i in range(1, self.settings["ikNb"] - 1):
            '''
            intMatrix = applyop.gear_intmatrix_op(
                self.ik_ctl[0] + ".matrix",
                self.ik_ctl[-1] + ".matrix",
                self.ik_att[i])
            # self.ik_uv_param[i])
            dm_node = node.createDecomposeMatrixNode(intMatrix + ".output")
            pm.connectAttr(dm_node + ".outputRotate", self.ik_npo[i].attr("rotate"))
            pm.connectAttr(dm_node + ".outputTranslate", self.ik_npo[i].attr("translate"))
            '''

            # TODO: connect attribute on weight
            s = [self.ik_ctl[0], self.ik_ctl[-1]]
            d = self.ik_npo[i]
            c = pm.parentConstraint(s, d, mo=True)

            for _i, _s in enumerate(s):
                pm.disconnectAttr("{}.{}W{}".format(c, _s, _i),
                                  "{}.target[{}].targetWeight".format(c, _i))

            inv = pm.createNode("floatMath")
            pm.setAttr(inv + ".floatA", 1.0)
            pm.setAttr(inv + ".operation", 1)
            pm.connectAttr(self.ik_att[i - 1], inv + ".floatB")
            pm.connectAttr(inv + ".outFloat", c + ".target[0].targetWeight")
            pm.connectAttr(self.ik_att[i - 1], c + ".target[1].targetWeight")
예제 #13
0
    def remove_light(self):
        '''
        # disconnect the selected light from the selected parti_volume node
        '''
        node = self.parti_scroll.getSelectItem()[0]
        light = self.parti_light_scroll.getSelectItem()[0]
        light_shape = self.parti_lights_dict[light].getShape()
        # listing the connections
        conn = cmds.listConnections('%s' % (light_shape), c=1, plugs=1)

        self.remove_index = ''

        print node, light, light_shape

        for c in conn:
            # checking if there's an attribute named:
            # '%s.lights' % (parti_volume_node)
            # if the attributes exist it wil return
            # '%s.lights[some #]' % (parti_volume_node)
            # so that way i can konw which index to use to disconnect the light
            if '%s.lights' % (node) in c:
                self.remove_index = conn[conn.index(c)]
                print self.remove_index

        try:
            pm.disconnectAttr('%s.message' % (light_shape),
                              '%s' % (self.remove_index))
        except:
            pm.disconnectAttr('%s.message' % (light),
                              '%s' % (self.remove_index))

        self.get_input_lights()

        self.reorder_input_lights()
예제 #14
0
파일: libRigging.py 프로젝트: renaudll/omtk
def connectAttr_withLinearDrivenKeys(attr_src, attr_dst, type='animCurveUU', force=True, kt=(-1.0,0.0,1.0), kv=(-1.0,0.0,1.0), kit=(4,2,4), kot=(4,2,4), pre='linear', pst='linear'):
    # Skip if a connection already exist
    for node in getAttrOutput(attr_src, plugs=False, skipBlendWeighted=True):
        if 'animCurveU' in node.type():
            drivenkey_outplugs = getAttrOutput(node.output, plugs=True, skipBlendWeighted=True)
            for drivenkey_outplug in drivenkey_outplugs:
                if drivenkey_outplug == attr_dst:
                    if force:
                        pymel.disconnectAttr(node.input)
                        pymel.disconnectAttr(node.output)
                        pymel.delete(node)
                    else:
                        print("Can't connect. Attribute {0} is already connected to {1} via {2}".format(
                            attr_src.longName(),
                            attr_dst.longName(),
                            drivenkey_outplug.node().longName()
                        ))
                        return

    animCurve = create_animCurveU('animCurveUU',
                                  kt=kt,
                                  kv=kv,
                                  kit=kit, # Spline/Linear/Spline
                                  kot=kot, # Spline/Linear/Spline
                                  pre=pre,
                                  pst=pst
                                  )
    animCurve.rename('{0}_{1}'.format(attr_src.node().name(), attr_src.longName()))
    pymel.connectAttr(attr_src, animCurve.input)
    return connectAttr_withBlendWeighted(animCurve.output, attr_dst)
예제 #15
0
    def createJoints(self, name=None, curve=None, num=None):
        ''' Create groups on curve. '''
        num = float(num)
        joints = []
        param_increment = 1.0/num
        param = 0
        curveshape = curve.getShape()
        prnt = []
        for i in range(int(num)):
            pm.select(clear=1)

            # create joint
            jnt = pm.joint(name='%s%s_jnt' % (name, i))
            joints.append(jnt)

            # attach to curve
            poci = pm.createNode('pointOnCurveInfo')
            pm.connectAttr('%s.ws' % curveshape, '%s.inputCurve' % poci, f=1)
            pm.connectAttr('%s.position' % poci, '%s.translate' % jnt, f=1)
            pm.setAttr('%s.turnOnPercentage' % poci, 1)
            pm.setAttr('%s.parameter' % poci, param)

            pm.disconnectAttr('%s.position' % poci, '%s.translate' % jnt)
            pm.delete(poci)

            if len(prnt):
                pm.parent(jnt, prnt[-1])

            prnt.append(jnt)
            param += param_increment

        return joints
예제 #16
0
def hold_connections(attrs, hold_inputs=True, hold_outputs=True):
    """
    Disconnect all inputs from the provided attributes but keep their in memory
    for ulterior re-connection.

    :param attrs: A list of pymel.Attribute instances.
    :type attrs: list of pymel.Attribute
    :param bool hold_inputs: Should we disconnect input connections?
    :param bool hold_outputs: Should we disconnect output connections?
    :return: The origin source and destination attribute for each entries.
    :rtype:list(tuple(src, str)
    """
    result = []
    for attr in attrs:
        if hold_inputs:
            attr_src = next(iter(attr.inputs(plugs=True)), None)
            if attr_src:
                pymel.disconnectAttr(attr_src, attr)
                result.append((attr_src, attr))
        if hold_outputs:
            for attr_dst in attr.outputs(plugs=True):
                pymel.disconnectAttr(attr, attr_dst)
                result.append((attr, attr_dst))

    return result
예제 #17
0
    def jointsOnCurve(self, crv=None, num=None, name=None):
	# Create n joint along selected curve
	if not crv: return
	if not num: return
	if not name: return
	if num < 1: return
	jnts = []
	param_increment = 1.0/float(int(num)+1)
	param = param_increment
	curveShape = pm.PyNode(crv).getShape()
	prnt = []
	for i in range(int(num)):
	    pm.select(clear=1)
	    # Create joint
	    jnt = pm.joint(n=name+'_'+str(i).zfill(2))
	    # Attach to curve
	    poci = pm.createNode('pointOnCurveInfo')
	    pm.connectAttr('%s.ws'%curveShape,'%s.inputCurve'%poci,f=1)
	    pm.connectAttr('%s.position'%poci,'%s.translate'%jnt,f=1)
	    pm.setAttr('%s.parameter'%poci,param)
	    pm.setAttr('%s.turnOnPercentage'%poci,1)
	
	    pm.disconnectAttr('%s.position'%poci,'%s.translate'%jnt)
	    pm.delete(poci)
	
	    if len(prnt):
		pm.parent(jnt,prnt[-1])
	
	    prnt.append(jnt)
	    param += param_increment
	    jnts.append(jnt)
	return jnts
예제 #18
0
def rtb_remove(highresListDropdown, *args, **kwargs):
    ''' remove item from the list and delete live-mesh and groups '''
    global defaultString
    global lct_cfg

    high = highresListDropdown.getValue()

    # restore interface selections
    highresListDropdown.setSelect(1)
    rtb_choose_active(highresListDropdown)

    if not high == defaultString:
        high = pm.PyNode(high.split("'")[0])  # get rid of unicode crap
        high.rename(re.sub(r'\_high$', '', str(high)))
        pm.parent(high, world=True)

        high.setScale([1, 1, 1])
        pm.disconnectAttr('persp.translate', high.scalePivot)

        if pm.displaySurface(high, query=True, xRay=True)[0] == True:
            pm.displaySurface(high, xRay=False)
        if not high.visibility.get():
            high.visibility.set(True)

        highShape = high.getShape()
        highShape.overrideDisplayType.set(0)  # sets to normal mode
        highShape.overrideEnabled.set(0)  # disable display overrides

        pm.delete(str(high) + '_RETOPO')

    rtb_highres_list_populate(highresListDropdown)

    lct_cfg.set('lcRetopoBasicListItem', highresListDropdown.getSelect())
    pm.select(clear=True)
예제 #19
0
    def createJoints(self, name=None, curve=None, num=None):
        ''' Create groups on curve. '''
        num = float(num)
        joints = []
        param_increment = 1.0 / num
        param = 0
        curveshape = curve.getShape()
        prnt = []
        for i in range(int(num)):
            pm.select(clear=1)

            # create joint
            jnt = pm.joint(name='%s%s_jnt' % (name, i))
            joints.append(jnt)

            # attach to curve
            poci = pm.createNode('pointOnCurveInfo')
            pm.connectAttr('%s.ws' % curveshape, '%s.inputCurve' % poci, f=1)
            pm.connectAttr('%s.position' % poci, '%s.translate' % jnt, f=1)
            pm.setAttr('%s.turnOnPercentage' % poci, 1)
            pm.setAttr('%s.parameter' % poci, param)

            pm.disconnectAttr('%s.position' % poci, '%s.translate' % jnt)
            pm.delete(poci)

            if len(prnt):
                pm.parent(jnt, prnt[-1])

            prnt.append(jnt)
            param += param_increment

        return joints
예제 #20
0
    def swap_anim(self):
        # First we disconnect the controllers from the anim curves
        for ctrl in [self.ctrl, self.mirrored_ctrl]:
            attributes = pm.listConnections(ctrl, c=True, type='animCurve') or []
            for pair in attributes:
                # if 'translate' in pair[0].name() or 'rotate' in pair[0].name():
                pm.disconnectAttr(pair[1].name() + '.output', pair[0].name())

        # We connect the source ctrl to the mirrored animcurves and offset them so there is the same start value as
        # the original
        for crv in self.mirror_anim_crv:
            attr_con = '.' + crv.name().split('_')[-1]
            pm.connectAttr(crv.name() + '.output', self.ctrl.name() + attr_con)
            # if 'translateX' in crv.name():
            #     pm.connectAttr(crv.name() + '.output', self.ctrl.name() + '.translateX')
            # if 'translateY' in crv.name():
            #     pm.connectAttr(crv.name() + '.output', self.ctrl.name() + '.translateY')
            # if 'translateZ' in crv.name():
            #     pm.connectAttr(crv.name() + '.output', self.ctrl.name() + '.translateZ')
            # if 'rotateX' in crv.name():
            #     pm.connectAttr(crv.name() + '.output', self.ctrl.name() + '.rotateX')
            # if 'rotateY' in crv.name():
            #     pm.connectAttr(crv.name() + '.output', self.ctrl.name() + '.rotateY')
            # if 'rotateZ' in crv.name():
            #     pm.connectAttr(crv.name() + '.output', self.ctrl.name() + '.rotateZ')

        # We connect the mirror ctrl to the source animcurves and offset them so there is the same start value as
        # the original
        for crv in self.anim_crv:
            attr_con = '.' + crv.name().split('_')[-1]
            pm.connectAttr(crv.name() + '.output', self.mirrored_ctrl.name() + attr_con)
    def __init__(self, name, baseObj, parentGrpName):
        self.name = name
        self.baseObj = baseObj
        self.parentGrpName = parentGrpName

        # Duplicate muscle control
        pm.duplicate(self.baseObj.name, n=self.name)

        # Delete the child squash and stretch curves. (Cross sections do not have.)
        children = pm.listRelatives(self.name, type='transform', path=True)
        # listRelatives returns a list
        if children:
            pm.delete(children)

        # Unlock transforms for reparenting
        attrList = [
            'translateX', 'translateY', 'translateZ', 'rotateX', 'rotateY',
            'rotateZ', 'scaleX', 'scaleY', 'scaleZ'
        ]
        for attr in attrList:
            pm.setAttr('%s.%s' % (self.name, attr), lock=False)

        # Make visible
        visibility = '%s.visibility' % self.name
        pm.setAttr(visibility, keyable=True)
        if pm.connectionInfo(visibility, isDestination=True):
            source = pm.connectionInfo(visibility, sourceFromDestination=True)
            pm.disconnectAttr(source, visibility)

        # Parent to parent grp
        pm.parent(self.name, parentGrpName)

        # Add muscle cross target to muscle controls's target list
        self.baseObj.addTarget(self.name)
예제 #22
0
파일: softTweaks.py 프로젝트: rusn07/mgear
def _createSoftModTweak(baseCtl, tweakCtl, name, targets):

    sm = pm.softMod(targets, wn=[tweakCtl, tweakCtl])
    pm.rename(sm[0], "{}_softMod".format(name))

    # disconnect default connection
    plugs = sm[0].softModXforms.listConnections(p=True)
    for p in plugs:
        pm.disconnectAttr(p, sm[0].softModXforms)
        pm.delete(p.node())

    dm_node = node.createDecomposeMatrixNode(baseCtl.worldMatrix[0])
    pm.connectAttr(dm_node.outputTranslate, sm[0].falloffCenter)
    mul_node = node.createMulNode(dm_node.outputScaleX,
                                  tweakCtl.attr("falloff"))
    pm.connectAttr(mul_node.outputX, sm[0].falloffRadius)
    mulMatrix_node = applyop.gear_mulmatrix_op(tweakCtl.worldMatrix[0],
                                               tweakCtl.parentInverseMatrix[0])
    pm.connectAttr(mulMatrix_node.output, sm[0].weightedMatrix)
    pm.connectAttr(baseCtl.worldInverseMatrix[0], sm[0].postMatrix)
    pm.connectAttr(baseCtl.worldMatrix[0], sm[0].preMatrix)
    attribute.addAttribute(sm[0], "_isSoftTweak", "bool", False, keyable=False)

    sm[0].addAttr("ctlRoot", at='message', m=False)
    sm[0].addAttr("ctlBase", at='message', m=False)
    sm[0].addAttr("ctlTweak", at='message', m=False)
    pm.connectAttr(baseCtl.getParent().attr("message"), sm[0].attr("ctlRoot"))
    pm.connectAttr(baseCtl.attr("message"), sm[0].attr("ctlBase"))
    pm.connectAttr(tweakCtl.attr("message"), sm[0].attr("ctlTweak"))

    return sm[0]
예제 #23
0
파일: guide.py 프로젝트: kyleMR/BoneForge
 def setHingeHandle(self, handle):
     existingHandle = self.hingeHandle()
     pm.disconnectAttr(self.guide.hingeMatrix)
     self.removeFromOrientGroup(handle)
     handle.transform.worldMatrix[0].connect(self.guide.hingeMatrix)
     if existingHandle and existingHandle != handle:
         self.moveToOrientGroup(existingHandle)
예제 #24
0
def decoJointLayer():
    mel.eval('SelectHierarchy')
    sel = pm.ls(sl = True)
    for s in sel:
        try:
            pm.disconnectAttr('jointLayer.drawInfo', '%s.drawOverride' % s)
        except Exception as ex:
            print(ex)
예제 #25
0
    def disconnect(self):
        # Disconnect internal influence from network
        attr_out = self._get_attr_out_world_tm()
        pymel.disconnectAttr(self.obj.worldMatrix, attr_out)

        # Disconnect external influence from network
        util_decompose_tm = self.obj_external.translate.inputs()[0]
        pymel.delete(util_decompose_tm)
예제 #26
0
파일: guide.py 프로젝트: kyleMR/BoneForge
 def setBaseHandle(self, handle):
     existingHandle = self.baseHandle()
     pm.disconnectAttr(self.guide.baseMatrix)
     self.removeFromOrientGroup(handle)
     handle.transform.worldMatrix[0].connect(self.guide.baseMatrix)
     if existingHandle and existingHandle != handle:
         self.moveToOrientGroup(existingHandle)
     self.snapOrientGroupHandlesToPlane()
예제 #27
0
def oriCns(driver, driven, maintainOffset=False):
    oriCns = pm.orientConstraint(driver, driven, maintainOffset=maintainOffset)
    for axis in "XYZ":
        pm.disconnectAttr(oriCns + ".constraintRotate" + axis,
                          driven + ".rotate" + axis)
    pm.connectAttr(oriCns + ".constraintRotate", driven + ".rotate", f=True)

    return oriCns
예제 #28
0
 def hold_attr(self, attr):
     if isinstance(attr, pymel.Attribute):
         for input in attr.inputs(plugs=True):
             if isinstance(input.node(), pymel.nodetypes.AnimCurve):
                 pymel.disconnectAttr(input, attr) # disconnect the animCurve so it won't get deleted automaticly after unbuilding the rig
                 return input
         return attr.get()
     return attr
	def illumDefaultCommand(self, *args):
		connections = pm.listConnections('defaultLightSet', d=False, s=True)
		if self.illDefault_box.getValue() == 0 and self.lightTransform in connections:
			defaultSet = pm.listConnections(self.lightTransform, d=True, s=False, plugs=True)[0]
			pm.disconnectAttr(self.lightTransform+'.instObjGroups[0]', defaultSet)

		elif self.illDefault_box.getValue() == 1:
			pm.connectAttr(self.lightTransform+'.instObjGroups',  'defaultLightSet.dagSetMembers', nextAvailable=True)
예제 #30
0
def disconnect_curve_from_xgen_guide(crv):
    # we asume that the curve is only connected to 1 description
    if not isinstance(crv, list):
        crv = [crv]
    for c in crv:
        cnx = c.worldSpace.listConnections(c=True, p=True)
        if cnx and len(cnx[0]) >= 2:
            pm.disconnectAttr(cnx[0][1])
 def conn(ctl, driver, ghost):
     for attr in ["translate", "scale", "rotate"]:
         try:
             pm.connectAttr("{}.{}".format(ctl, attr),
                            "{}.{}".format(driver, attr))
             pm.disconnectAttr("{}.{}".format(ctl, attr),
                               "{}.{}".format(ghost, attr))
         except RuntimeError:
             pass
예제 #32
0
def udimexnode(arg):
    filesel =pm.ls(sl=1,type="file")
    if filesel!=[]:
        for i in range(len(filesel)):
            filemode = pm.getAttr(filesel[i]+".uvTilingMode")
            if filemode ==3:
                pm.setAttr(filesel[i]+".uvTilingMode",0)
                baseptnode = pm.listConnections(filesel[i],d=0,type="place2dTexture")[0]
                pm.setAttr(baseptnode+".wrapU",0)
                pm.setAttr(baseptnode+".wrapV",0)
                filepath  =pm.getAttr(filesel[i]+".fileTextureName").replace("\\","/")
                type =filepath.split(".")[-1]
                adjname =os.path.basename(filepath)[:-len(type)-6]
                dirname = os.path.dirname(filepath)
                filelist = pm.getFileList(fld = dirname)
                fileseled = []
                for f in range(len(filelist)):
                    listype = filelist[f].split(".")[-1]
                    listadj = os.path.basename(filelist[f])[:-len(listype)-6]
                    if listadj == adjname:
                        fileseled.append(dirname+"/"+filelist[f])
                filenodeas = []
                for l in range(1,len(fileseled)):
                    types =fileseled[l].split(".")[-1]
                    vvalue =int(fileseled[l][:-len(types)-1][-2])
                    uvalue = int(fileseled[l][:-len(types)-1][-1])-1
                    if types!="tx":
    #                    print fileseled[l],vvalue,uvalue
                        filenode =pm.shadingNode("file",asTexture=1,name=filesel[i])
                        pm.setAttr(filenode+".fileTextureName",fileseled[l],type="string")
                        ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=filesel[i])
                        pm.setAttr(ptnode+".translateFrameU",int(uvalue))
                        pm.setAttr(ptnode+".translateFrameV",int(vvalue))
                        pm.setAttr(ptnode+".wrapU",0)
                        pm.setAttr(ptnode+".wrapV",0)
                        filenodebuild().builder(ptnode,filenode)
                        filenodeas.append(filenode)
                        fnum = len(filenodeas)
                        if fnum==1:
                            pm.connectAttr(filenodeas[fnum-1]+".outColor",filesel[i]+".defaultColor",f=1)
                        else:
                            pm.connectAttr(filenodeas[fnum-1]+".outColor",filenodeas[fnum-2]+".defaultColor",f=1)
            else:
                if pm.listConnections(filesel[i]+".defaultColor",d=0)!=[]:
                    
                    filein  = pm.listConnections(filesel[i]+".defaultColor",d=0,plugs=1)
                    pm.disconnectAttr(filein[0],filesel[i]+".defaultColor")
                    ptfile = pm.listConnections(filesel[i],d=0,type="place2dTexture")
                    pm.setAttr(ptfile[0]+".wrapU",1)
                    pm.setAttr(ptfile[0]+".wrapV",1)
                    pm.setAttr(ptfile[0]+".translateFrameU",0)
                    pm.setAttr(ptfile[0]+".translateFrameV",0)
                    pm.setAttr(filesel[i]+".uvTilingMode",3)
                    mel.eval('hyperShadePanelMenuCommand("hyperShadePanel", "deleteUnusedNodes");') 
    else:
        print "请选择需要转换的file节点!!",
예제 #33
0
def hairtransfer(hairsrmesh,hairtrmesh):
    hairsyssels=[]
    filename =os.path.basename( cmds.file(expandName=1,q=1)).split(".")[0]
    hairwhole = pm.group(em=1,name=filename+"_hair_G")
    folwhole = pm.group(em=1,name=filename+"_fols_G")
    cvswhole = pm.group(em=1,name=filename+"_outputCvs_G")
    pfxwhole = pm.group(em=1,name=filename+"_pfxHairs_G")
    try:
        hairShapesr =  hairsrmesh.getShape()
        hairShapetr =  hairtrmesh.getShape()
    except:
        hairShapesr=[]
        hairShapetr=[]
        pm.warning(selsrs[i]+"'s shapeNode is not exists!!")
    follicles =  pm.listConnections(hairShapesr,s=0,type="follicle")
    if follicles!=None:
        for follicle in follicles:
            follicleshape =  follicle.getShape()
            hairsyssel = pm.listConnections( follicleshape+".outHair",s=0,type="hairSystem")[0]
            if hairsyssel not in hairsyssels:
                hairsyssels.append(hairsyssel)
                pfxhairsel = pm.listConnections( hairsyssel+".outputRenderHairs",s=0,type="pfxHair")[0]
                pm.parent(pfxhairsel,pfxwhole)
                folliclesels = pm.listConnections( hairsyssel+".inputHair",d=0)
                cvs = [pm.listConnections(a+".outCurve",s=0)[0] for a in folliclesels]
                for cv in cvs:
                    cvsconnects= pm.listConnections(cv.getShape(),c=1,plugs=1)[0]
                    pm.disconnectAttr(cvsconnects[1],cvsconnects[0])
                cvsgrp =pm.group(cvs,name=str(hairsyssel)+"_cvs_g")
                pm.select(hairtrmesh,r=1)
                pm.select(cvsgrp,tgl=1)
                mel.eval('makeCurvesDynamic 2 { "1", "1", "1", "1", "1"};')
                newfollicles = [b.getParent() for b in cvs if b.getParent().getShape()!=None]
                newcvs = [pm.listConnections(a+".outCurve",s=0)[0] for a in newfollicles ]
                oldhairsys =[pm.listConnections(a.getShape()+".outHair",s=0,type="hairSystem")[0] for a in newfollicles]
                oldhairsys = list(set(oldhairsys))
                nucleussels =[pm.listConnections(a.getShape(),s=0,type="nucleus")[0] for a in oldhairsys]
                nucleussels = list(set(nucleussels))
                pm.delete(oldhairsys,nucleussels)
                pm.select(newfollicles,r=1)
                mel.eval('assignHairSystem %s'%(hairsyssel))
                try:
                    pm.parent(hairsyssel+"Follicles",folwhole)
                    
                    pm.parent(hairsyssel+"OutputCurves",cvswhole)
                    pm.setAttr(hairsyssel+"OutputCurves.visibility",0)
                except:
                    pm.warning('cant not parent Follicles and OutputCurves group!!')
    hairsystrsgrp = pm.group(hairsyssels,name = filename+"_hairSystems_G")      
    pm.parent(pfxwhole,hairwhole)       
    pm.parent(hairsystrsgrp,hairwhole)
    pm.setAttr(hairsystrsgrp+".visibility",0)
    pm.parent(folwhole,hairwhole)
    pm.setAttr(folwhole+".visibility",0)
    pm.parent(cvswhole,hairwhole)
    pm.setAttr(cvswhole+".visibility",0)
예제 #34
0
 def setParent(self, other):
     """Set the parent Handle."""
     parentHandle = self.parent()
     if parentHandle:
         pm.disconnectAttr(self.node.parentHandle)
         parentHandle.removeChild(self)
     if other is not None:
         other.node.message.connect(self.node.parentHandle)
         other.transform.worldMatrix[0].connect(self.node.parentHandleMatrix)
         other.addChild(self)
예제 #35
0
 def _remap_attr(attr_):
     attr_ = (pymel.Attribute(attr_)
              if isinstance(attr_, basestring) else None)  # conform
     attr_src = next(iter(attr_.inputs(plugs=True)), None)
     if attr_src:
         pymel.disconnectAttr(attr_src, attr_)
     for attr_dst in attr_.outputs(plugs=True):
         pymel.disconnectAttr(attr_, attr_dst)
         if attr_src:
             pymel.connectAttr(attr_src, attr_dst, force=True)
예제 #36
0
    def addOperators(self):
        super(Component, self).addOperators()

        for shp in self.ikcns_ctl.getShapes():
            try:
                pm.disconnectAttr(self.blend_att, shp.attr("visibility"))
                shp.setAttr("visibility", False)
            except RuntimeError:
                pass
        att.setKeyableAttributes(self.ikcns_ctl, [])
예제 #37
0
def deleteConnection(plug):
    if pm.connectionInfo(plug, isDestination=True):
        plug = pm.connectionInfo(plug, getExactDestination=True)
        readOnly = pm.ls(plug, ro=True)
        #delete -icn doesn't work if destination attr is readOnly
        if readOnly:
            source = pm.connectionInfo(plug, sourceFromDestination=True)
            pm.disconnectAttr(source, plug)
        else:
            pm.delete(plug, icn=True)
예제 #38
0
    def hold_avars(self):
        """
        Create a network to hold all the avars complex connection.
        This prevent Maya from deleting our connection when unbuilding.
        """
        if self.grp_rig is None or not self.grp_rig.exists():
            self.warning(
                "Can't hold avars, invalid grp_rig in {0}!".format(self))
            return

        self.avar_network = pymel.createNode(
            'transform',
            name=self.get_nomenclature_rig().resolve('avarBackup'))
        self.rig.hold_node(self.avar_network)
        self.add_avars(self.avar_network)

        def attr_have_animcurve_input(attr):
            attr_input = next(
                iter(attr.inputs(plugs=True, skipConversionNodes=True)), None)
            if attr_input is None:
                return False

            attr_input_node = attr_input.node()

            if isinstance(attr_input_node, pymel.nodetypes.AnimCurve):
                return True

            if isinstance(attr_input_node, pymel.nodetypes.BlendWeighted):
                for blendweighted_input in attr_input_node.input:
                    if attr_have_animcurve_input(blendweighted_input):
                        return True

            return False

        attrs = pymel.listAttr(self.avar_network, userDefined=True)
        for attr_name in attrs:
            if not self.grp_rig.hasAttr(attr_name):
                self.warning("Cannot hold missing attribute {0} in {1}".format(
                    attr_name, self.grp_rig))
                continue

            #attr_name = attr.longName()
            attr_src = self.grp_rig.attr(attr_name)
            attr_dst = self.avar_network.attr(attr_name)
            # libAttr.transfer_connections(attr_src, attr_dst)

            if attr_have_animcurve_input(attr_src):
                attr_src_inn = next(iter(attr_src.inputs(plugs=True)), None)
                pymel.disconnectAttr(attr_src_inn, attr_src)
                pymel.connectAttr(attr_src_inn, attr_dst)

            # Transfer output connections
            for attr_src_out in attr_src.outputs(plugs=True):
                pymel.disconnectAttr(attr_src, attr_src_out)
                pymel.connectAttr(attr_dst, attr_src_out)
예제 #39
0
    def hold_avars(self):
        """
        Create a network to hold all the avars complex connection.
        This prevent Maya from deleting our connection when unbuilding.
        """
        if self.grp_rig is None or not self.grp_rig.exists():
            self.warning("Can't hold avars, invalid grp_rig in {0}!".format(self))
            return

        self.avar_network = pymel.createNode(
            'transform',
            name=self.get_nomenclature_rig().resolve('avarBackup')
        )
        self.rig.hold_node(self.avar_network)
        self.add_avars(self.avar_network)

        def attr_have_animcurve_input(attr):
            attr_input = next(iter(attr.inputs(plugs=True, skipConversionNodes=True)), None)
            if attr_input is None:
                return False

            attr_input_node = attr_input.node()

            if isinstance(attr_input_node, pymel.nodetypes.AnimCurve):
                return True

            if isinstance(attr_input_node, pymel.nodetypes.BlendWeighted):
                for blendweighted_input in attr_input_node.input:
                    if attr_have_animcurve_input(blendweighted_input):
                        return True

            return False

        attrs = pymel.listAttr(self.avar_network, userDefined=True)
        for attr_name in attrs:
            if not self.grp_rig.hasAttr(attr_name):
                self.debug("Cannot hold missing attribute {0} in {1}".format(attr_name, self.grp_rig))
                continue

            # attr_name = attr.longName()
            attr_src = self.grp_rig.attr(attr_name)
            attr_dst = self.avar_network.attr(attr_name)
            # libAttr.transfer_connections(attr_src, attr_dst)

            # if attr_have_animcurve_input(attr_src):
            attr_src_inn = next(iter(attr_src.inputs(plugs=True)), None)
            if attr_src_inn:
                pymel.disconnectAttr(attr_src_inn, attr_src)
                pymel.connectAttr(attr_src_inn, attr_dst)

            # Transfer output connections
            for attr_src_out in attr_src.outputs(plugs=True):
                pymel.disconnectAttr(attr_src, attr_src_out)
                pymel.connectAttr(attr_dst, attr_src_out)
예제 #40
0
def transfer_connections(attr_src, attr_dst):
    # Transfer input connections
    attr_src_inn = next(iter(attr_src.inputs(plugs=True)), None)
    if attr_src_inn:
        pymel.disconnectAttr(attr_src_inn, attr_src)
        pymel.connectAttr(attr_src_inn, attr_dst)

    # Transfer output connections
    for attr_src_out in attr_src.outputs(plugs=True):
        pymel.disconnectAttr(attr_src, attr_src_out)
        pymel.connectAttr(attr_dst, attr_src_out)
예제 #41
0
	def removeConnections( self, objs = None, *args ):
		# disconnect all connections.
		if objs==None:
			objs = pm.ls( sl=True )
		else:
			objs = pm.ls( objs )
		
		for obj in objs:
			connections = pm.listConnections( obj, connections=True, destination=False, skipConversionNodes=True, plugs=True  )
			for connection in connections:
				pm.disconnectAttr( connection[1], connection[0] )
예제 #42
0
파일: libAttr.py 프로젝트: renaudll/omtk
def transfer_connections(attr_src, attr_dst):
    # Transfer input connections
    attr_src_inn = next(iter(attr_src.inputs(plugs=True)), None)
    if attr_src_inn:
        pymel.disconnectAttr(attr_src_inn, attr_src)
        pymel.connectAttr(attr_src_inn, attr_dst)

    # Transfer output connections
    for attr_src_out in attr_src.outputs(plugs=True):
        pymel.disconnectAttr(attr_src, attr_src_out)
        pymel.connectAttr(attr_dst, attr_src_out)
def multi_illDefault(*args):
	sel_lights = pm.ls(sl=True, lights=True, dag=True)
	connections = pm.listConnections('defaultLightSet', d=False, s=True)

	for each in sel_lights:
		trans = pm.listRelatives(each, parent=True, fullPath=True)[0]
		if multi_illDefault_box.getValue() == 0 and trans in connections:
			defaultSet = pm.listConnections(trans, d=True, s=True, plugs=True)[0]
			pm.disconnectAttr(trans+'.instObjGroups[0]', defaultSet)

		elif multi_illDefault_box.getValue() == 1:
			pm.connectAttr(trans+'.instObjGroups',  'defaultLightSet.dagSetMembers', nextAvailable=True)
예제 #44
0
 def reconnectAnimationCurves(self, src, dst):
     for transform in ['translate', 'rotate']:
         for axis in ['X', 'Y', 'Z']:
             # If attribute has a connection (anim curve) means it's animated
             src_attr = '%s.%s%s'%(src, transform, axis)
             dst_attr = '%s.%s%s'%(dst, transform, axis)
             if pc.connectionInfo(src_attr, id=True):
                 conn = pc.connectionInfo(src_attr, sfd=True)
                 pc.connectAttr(conn, dst_attr)
                 pc.disconnectAttr(conn, src_attr)
             else:
                 pc.setAttr(dst_attr, pc.getAttr(src_attr))
예제 #45
0
파일: libRigging.py 프로젝트: renaudll/omtk
def create_animCurveU(type, kt, kv, kit=None, kot=None, kix=None, kiy=None, kox=None, koy=None, pre=0, pst=0):
    """
    :param type:
    :param keys: A tuple containing the following values: key time, key value
    :param pre:
    :param post:
    :return:
    """
    # Use a temporary node to create the curve
    tmp = pymel.createNode('transform')

    # Resolve the attributes we'll want to "connect"
    att_src = tmp.sx
    att_dst = None
    if type == 'animCurveUU':
        att_dst = tmp.sy
    elif type == 'animCurveUL':
        att_dst = tmp.tx
    elif type == 'animCurveUA':
        att_dst = tmp.rx
    else:
        raise NotImplemented("Unexpected animCurve type. Got {0}.".format(type))

    # Create keys
    for key_time, key_val in zip(kt, kv):
        att_src.set(key_time)
        att_dst.set(key_val)
        pymel.setDrivenKeyframe(att_dst, cd=att_src)

    # Get curve and delete tmp object
    curve = next(iter(att_dst.inputs()))
    pymel.disconnectAttr(curve.output, att_dst)
    pymel.disconnectAttr(att_src, curve.input)
    pymel.delete(tmp)

    curve.setPreInfinityType(pre)
    curve.setPostInfinityType(pst)

    num_keys = len(kt)
    if kit:
        for i, ti in zip(range(num_keys), kit):
            curve.setInTangentType(i, ti)
    if kot:
        for i, to in zip(range(num_keys), kot):
            curve.setOutTangentType(i, to)
    if kix and kiy:
        for i, tix, tiy in zip(range(num_keys), kix, kiy):
            curve.setTangent(i, tix, tiy, True)
    if kox and koy:
        for i, tox, toy in zip(range(num_keys), kox, koy):
            curve.setTangent(i, tox, toy, False)

    return curve
예제 #46
0
파일: libAttr.py 프로젝트: Leopardob/omtk
def disconnectAttr(attr, inputs=True, outputs=True):
    attr_is_locked = attr.isLocked()
    if attr_is_locked: attr.unlock()

    if inputs:
        for attr_in in attr.inputs(plugs=True):
            pymel.disconnectAttr(attr_in, attr)
    if outputs:
        for attr_out in attr.outputs(plugs=True):
            pymel.disconnectAttr(attr, attr_out)

    if attr_is_locked: attr.lock()
예제 #47
0
    def on_action_axisChange(self, iRow, iCol, *args):
        pCell = self.ui.tblData.item(iRow,iCol)
        pData = pCell.data(QtCore.Qt.UserRole)

        pData.nChildLoc.axis.set(args[0])

        #Delete old connection
        pymel.disconnectAttr(pData.nMD.input1X)

        lstXCon = pData.nDecM.outputRotateX.listConnections()
        pymel.disconnectAttr(pData.nDecM.outputRotateX)
        pymel.delete(lstXCon)

        lstYCon = pData.nDecM.outputRotateY.listConnections()
        pymel.disconnectAttr(pData.nDecM.outputRotateY)
        pymel.delete(lstYCon)

        lstZCon = pData.nDecM.outputRotateZ.listConnections()
        pymel.disconnectAttr(pData.nDecM.outputRotateZ)
        pymel.delete(lstZCon)

        if args[0] == 0:
            pymel.connectAttr(pData.nDecM.outputRotateX, pData.nMD.input1X, f=True)
        elif args[0] == 1:
             pymel.connectAttr(pData.nDecM.outputRotateY, pData.nMD.input1X, f=True)
        elif args[0] == 2:
             pymel.connectAttr(pData.nDecM.outputRotateZ, pData.nMD.input1X, f=True)
예제 #48
0
 def reorder_input_lights(self):
     '''
     # this will reorder the light connections
     # so adding the lights will be easier
     # that way i can just add a light based
         on the len(self.parti_lights)
     # connectAttr(light.message, node.lights[len(self.parti_lights)])    
     '''
     node = self.parti_scroll.getSelectItem()[0]
     temp_remove_index = ''
     
     # removing the connections
     for light in self.parti_lights:
         light_shape = light.getShape()
         conn = cmds.listConnections('%s' % (light), c= 1, plugs= 1)
         for c in conn:
         # checking if there's an attribute named:
         # '%s.lights' % (parti_volume_node)
         # if the attributes exist it wil return
         # '%s.lights[some #]' % (parti_volume_node)
         # so that way i can konw which index to use to disconnect the light
             if '%s.lights' % (node) in c:
                 temp_remove_index = conn[conn.index(c)]
                 
             try:
                 pm.disconnectAttr('%s.message' % (light_shape),
                                 '%s' % (temp_remove_index))
                 
             except:
                 pass
                 
             
                 
     # reconnecting everything
     # but in order
     i = 0
     while i < len(self.parti_lights):
         
         try:
             pm.connectAttr('%s.message' % (self.parti_lights[i].getShape()),
                         '%s.lights[%s]' % (node, str(i)))
             
         except:
             pass
         
         i += 1
                 
       
     self.get_input_lights()
예제 #49
0
파일: libAttr.py 프로젝트: renaudll/omtk
def hold_attrs(attr):
    """
    Hold a specific @attr attribute.
    """
    if isinstance(attr, pymel.Attribute):
        for input in attr.inputs(plugs=True):
            if not attr.isLocked():
                if isinstance(input.node(), (pymel.nodetypes.AnimCurve, pymel.nodetypes.BlendWeighted)):
                    pymel.disconnectAttr(input, attr)  # disconnect the animCurve so it won't get deleted automaticly after unbuilding the rig
                    return input
            else:
                log.warning("Input have been found on attr {0}, but it's locked. "
                            "The animation curve will be lost and the current value will be used".format(attr))
        return attr.get()
    return attr
예제 #50
0
def disconnect_layers( layers ):
  layer_nodes = [ ]
  for layer in layers:
    node = get_bake_layer( layer )
    if not node == False:
      layer_nodes.append( node )
        
  for layer in layer_nodes:
    connect_attr = layer.attr( HIGH_CONNECT_ATTR )
    

    for plug in pmc.connectionInfo( connect_attr, destinationFromSource = True ):
      if pmc.PyNode( plug.split( '.' )[ 0 ] ) in layer_nodes:
      
        pmc.disconnectAttr( connect_attr, plug )
예제 #51
0
 def Maya_focusOn(self, attribute, *args):
     """Displays attribute input on a aiUtility flat surface"""
     
     # Check if dummy shader exists, create it if not
     if len(pc.ls('dummySHD')) == 0:
         print("#INFO# '{0}' // Dummy shader not present. Creating.".format(self.selectedShader))
         # ShadingGroup creation
         sg = pc.sets(renderable=True, noSurfaceShader=True, empty=True, name="aiUtilitySG")
         # aiUtility creation
         aiUtility = pc.shadingNode("aiUtility", asShader=True, name="dummySHD")
         aiUtility.outColor >> sg.surfaceShader
         # Set shade mode to flat
         aiUtility.shadeMode.set('flat')
     
     # Get the aiUtility node    
     aiUtility = pc.PyNode('dummySHD')
     
     # Clear connections if they exist
     connections = aiUtility.listConnections(d=False, c=True, p=True)
     for con in connections:
         pc.disconnectAttr(con[1], con[0])
         
     # Return input node
     inputNode = self.Maya_getInput(self.selectedShader, attribute)
     
     print inputNode
     
     if inputNode != (None, None):
         # Make the connections    
         myNode = pc.PyNode(inputNode[0])
         
         if inputNode[1] == 'outNormal':
             # Bump case
             inputNodeBump = self.Maya_getInput(inputNode[0], 'bumpValue')
             
             myNode = pc.PyNode(inputNodeBump[0])
             
         if inputNode[1] == 'outAlpha':
             myNode.attr(inputNode[1]).connect(aiUtility.color.colorR)
             myNode.attr(inputNode[1]).connect(aiUtility.color.colorG)
             myNode.attr(inputNode[1]).connect(aiUtility.color.colorB)
         elif inputNode[1] == 'outColor':
             myNode.attr(inputNode[1]).connect(aiUtility.color)
             
         # Select all objets with current shader and assign dummySHD
         self.Maya_replaceMaterial(self.selectedShader, 'dummySHD')
     else:
         self.User_warningDialog("Error", "Nothing is connected to %s" % self.selectedShader + '.' + attribute)
예제 #52
0
    def disconnect(self):
        # Disconnect external ctrl from network
        attr_inn = self._get_attr_inn_ctrl_local_tm()
        pymel.disconnectAttr(self.external_ctrl.matrix, attr_inn)

        # Disconnect network from internal ctrl
        util_decompose_tm = self.obj.inputs()[0]
        pymel.delete(util_decompose_tm)

        # Disconnect internal offset from network
        attr_out = self._get_attr_out_ctrl_offset_world_tm()
        pymel.disconnectAttr(self.obj_offset.worldMatrix, attr_out)

        # Diconnect output network from external ctrl offset
        util_decompose_tm = self.external_ctrl_offset.inputs()[0]
        pymel.delete(util_decompose_tm)
예제 #53
0
def remove_from_bake_layer( layer, objects = None ):
  if objects == None:
    objects = pmc.ls( sl = True )

  node = get_bake_layer( layer )
  if node == False:
    pmc.error( 'You must specify a Bake Layer for this command' )
    return False
      
  connect_attr = node.attr( LAYER_MEMBERS_ATTR )
  

  for plug in pmc.connectionInfo( connect_attr, destinationFromSource = True ):
    if pmc.PyNode( plug.split( '.' )[ 0 ] ) in objects:
    
      pmc.disconnectAttr( connect_attr, plug )
예제 #54
0
파일: curve.py 프로젝트: pfleer/python
 def _attach_to_curve(self, child, cv):
     """
     @note: attach to curve using motion path
     @param child: object to be attached
     @param cv: cv index
     @param fm: fraction mode, allows U values 0 to 1
     @return:
     """
     # attach to motion path
     # @param: fm = fraction mode
     motion_path = mc.pathAnimation(child, str(self.name), fm=True)
     # break U value connection of motion path
     pm.disconnectAttr('{}_uValue.output'.format(motion_path))
     # set U value
     spacing = 1.0 / (self.cvs - 1)
     u_position = spacing * cv
     pm.setAttr('{}.uValue'.format(motion_path), u_position)
예제 #55
0
파일: rigFaceAvar.py 프로젝트: goujin/omtk
    def hold_avars(self):
        """
        Create a network to hold all the avars complex connection.
        This prevent Maya from deleting our connection when unbuilding.
        """
        if self.grp_rig is None:
            log.warning("Can't hold avars, no grp_rig found in {0}!".format(self))
            return

        self.avar_network = pymel.createNode('network')
        self.add_avars(self.avar_network)

        def attr_have_animcurve_input(attr):
            attr_input = next(iter(attr.inputs(plugs=True, skipConversionNodes=True)), None)
            if attr_input is None:
                return False

            attr_input_node = attr_input.node()

            if isinstance(attr_input_node, pymel.nodetypes.AnimCurve):
                return True

            if isinstance(attr_input_node, pymel.nodetypes.BlendWeighted):
                for blendweighted_input in attr_input_node.input:
                    if attr_have_animcurve_input(blendweighted_input):
                        return True

            return False

        attrs = pymel.listAttr(self.avar_network, userDefined=True)
        for attr_name in attrs:
            #attr_name = attr.longName()
            attr_src = self.grp_rig.attr(attr_name)
            attr_dst = self.avar_network.attr(attr_name)
            # libAttr.transfer_connections(attr_src, attr_dst)

            if attr_have_animcurve_input(attr_src):
                attr_src_inn = next(iter(attr_src.inputs(plugs=True)), None)
                pymel.disconnectAttr(attr_src_inn, attr_src)
                pymel.connectAttr(attr_src_inn, attr_dst)

            # Transfer output connections
            for attr_src_out in attr_src.outputs(plugs=True):
                pymel.disconnectAttr(attr_src, attr_src_out)
                pymel.connectAttr(attr_dst, attr_src_out)
예제 #56
0
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
예제 #57
0
def swapConnections(plugname, i_zero, i_one):

    dstPlug_zero = '%s[%s]'%(plugname, i_zero)
    dstPlug_one = '%s[%s]'%(plugname, i_one)
    srcPlug_zero = getSourcePlug(dstPlug_zero, -1)
    srcPlug_one = getSourcePlug(dstPlug_one, -1)

    if srcPlug_zero != "":
        pm.disconnectAttr(srcPlug_zero, dstPlug_zero)

    if srcPlug_one != "":
        pm.disconnectAttr(srcPlug_one, dstPlug_one)

    if srcPlug_zero != "":
        pm.connectAttr(srcPlug_zero, dstPlug_one)

    if srcPlug_one != "":
        pm.connectAttr(srcPlug_one, dstPlug_zero)
예제 #58
0
def _createNurbsSurfaceFromNurbsCurve(_curve, _width=0.1):
    nurbsMin = pymel.duplicate(_curve)[0]
    nurbsMax = pymel.duplicate(_curve)[0]
    nurbsMin.tz.set(nurbsMin.tz.get() - _width)
    nurbsMax.tz.set(nurbsMin.tz.get() + _width)

    loft = pymel.createNode('loft')
    pymel.connectAttr(nurbsMin.worldSpace, loft.inputCurve[0])
    pymel.connectAttr(nurbsMax.worldSpace, loft.inputCurve[1])

    surface = pymel.createNode('nurbsSurface')
    pymel.connectAttr(loft.outputSurface, surface.create)

    pymel.disconnectAttr(loft.outputSurface, surface.create)
    pymel.delete(loft)
    pymel.delete(nurbsMin)
    pymel.delete(nurbsMax)

    return surface
예제 #59
0
    def fetch_avars(self):
        """
        If a previously created network have be created holding avars connection,
        we'll transfert thoses connections back to the grp_rig node.
        Note that the avars have to been added to the grp_rig before..
        """
        if libPymel.is_valid_PyNode(self.avar_network):
            for attr_name in pymel.listAttr(self.avar_network, userDefined=True):
                attr_src = self.avar_network.attr(attr_name)
                if not self.grp_rig.hasAttr(attr_name):
                    self.warning("Can't fetch stored avar named {0}!".format(attr_name))
                    continue
                attr_dst = self.grp_rig.attr(attr_name)
                libAttr.transfer_connections(attr_src, attr_dst)

            # Ensure Maya don't delete our networks when removing the backup node...
            pymel.disconnectAttr(self.avar_network.message)
            pymel.delete(self.avar_network)
            self.avar_network = None