當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.listConnections方法代碼示例

本文整理匯總了Python中maya.cmds.listConnections方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.listConnections方法的具體用法?Python cmds.listConnections怎麽用?Python cmds.listConnections使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.listConnections方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dpLoadBSNode

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def dpLoadBSNode(self, *args):
        """ Load selected object as blendShapeNode
        """
        selectedList = cmds.ls(selection=True)
        if selectedList:
            if cmds.objectType(selectedList[0]) == "blendShape":
                cmds.textField(self.bsNodeTextField, edit=True, text=selectedList[0])
                self.dpLoadBSTgtList(selectedList[0])
                self.bsNode = selectedList[0]
            elif cmds.objectType(selectedList[0]) == "transform":
                meshList = cmds.listRelatives(selectedList[0], children=True, shapes=True, noIntermediate=True, type="mesh")
                if meshList:
                    bsNodeList = cmds.listConnections(meshList[0], type="blendShape")
                    if bsNodeList:
                        self.dpLoadBSTgtList(bsNodeList[0])
                        self.bsNode = bsNodeList[0]
                    else:
                        mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
                else:
                    mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
            else:
                mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
        else:
            mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";") 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:26,代碼來源:dpFacialControl.py

示例2: initialize_filtering

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def initialize_filtering(self):
        # texture filter
        if self.use_tex:
            try:
                texture = cmds.listConnections('{}.emitTexture'.format(self.node_name))[0]
            except RuntimeError:
                texture = None

            if texture:
                self.evaluate_uvs()
                self.texture_filter(texture, 0) # TODO - Filter size

        # altitude filter
        if self.min_altitude != 0 or self.max_altitude != 1:
            self.altitude_filter(self.min_altitude, self.max_altitude, self.min_altitude_fuzz, self.max_altitude_fuzz)

        # slope filter
        if self.min_slope != 0 or self.max_slope != 180:
            self.slope_filter(self.min_slope, self.max_slope, self.slope_fuzz) 
開發者ID:wiremas,項目名稱:spore,代碼行數:21,代碼來源:spore_sampler.py

示例3: get_all_tag_children

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def get_all_tag_children(node):
    """Gets all child tag controls from the given tag node

    Args:
        node (dagNode): Controller object with tag

    Returns:
        list: List of child controls (Maya transform nodes)
    """

    # store child nodes
    children = []

    # gets first child control
    child = cmds.controller(node, query=True, children=True)

    # loop on child controller nodes to get all children
    while child is not None:
        children.extend(child)
        tag = cmds.ls(cmds.listConnections(child[0], type="controller"))
        if cmds.listConnections("{}.parent".format(tag[0])) == node:
            return children
        child = cmds.controller(tag, query=True, children=True)

    return children 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:27,代碼來源:pickWalk.py

示例4: select_all_child_controls

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def select_all_child_controls(control, *args):  # @unusedVariable
    """ Selects all child controls from the given control

    This function uses Maya's controller nodes and commands to find relevant
    dependencies between controls

    Args:
        control (str): parent animation control (transform node)
        *args: State of the menu item (if existing) send by mgear's dagmenu
    """

    # gets controller node from the given control. Returns if none is found
    tag = cmds.ls(cmds.listConnections(control), type="controller")
    if not tag:
        return

    # query child controls
    children = get_all_tag_children(tag)

    # adds to current selection the children elements
    cmds.select(children, add=True) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:23,代碼來源:anim_utils.py

示例5: BT_ConnectSetup

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def BT_ConnectSetup(set = None):

    if not set or not cmds.objExists(set):
        return False

    if BT_IsSetupConnected(set = set):
        cmds.warning('Setup already connected!')
        return False
    
    btNode = cmds.getAttr(set +'.Blend_Node')
    if not btNode or not cmds.objExists(btNode):
        return False

    transforms = cmds.listConnections(set +'.dagSetMembers')
    for i in range(0, len(transforms)):
        try:
            BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i])
        except:
            pass

    mults = cmds.listConnections(btNode, d = True, type = 'multiplyDivide')
    if mults:
        cmds.delete(mults)

    return True 
開發者ID:duncanskertchly,項目名稱:BlendTransforms,代碼行數:27,代碼來源:BlendTransforms.py

示例6: __iter__

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def __iter__(self):
		mapSets = dict()
		cons = cmds.listConnections(
			self.name() + '.surfaceShader',
		) or []
		for con in cons:
			maps = cmds.listConnections(
				con,
				plugs=True,
				type='file',
			) or []
			for mapSpec in maps:
				(name, plug) = re.split(r'[.]', mapSpec)
				mapPath = os.path.normpath(cmds.getAttr(name + '.fileTextureName'))
				if mapPath and MaterialPropertyMap.hasKey(plug):
					mapSets[MaterialPropertyMap.valueByLabel(plug)] = mapPath
				else:
					mapSets[plug] = mapPath
		yield ('name', self.name())
		yield ('maps', mapSets)
		yield ('objects', [o.name() for o in self.objects()]) 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:23,代碼來源:mayascenematerial.py

示例7: connectRenderMeshes

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def connectRenderMeshes(self, renderMeshes, LOD=0):
        try:
            cmds.undoInfo(openChunk=True)
            lodAttr = None
            if LOD >=0 or LOD <=4:
                lodAttr = self.node + '.rendermeshes_LOD' + str(LOD)
                conns = cmds.listConnections(lodAttr, plugs=1, destination=1)
                if conns:
                    for conn in cmds.listConnections(lodAttr, plugs=1, destination=1):
                        cmds.disconnectAttr(lodAttr, conn)
            if lodAttr:
                for mesh in renderMeshes:
                    msgConnect(lodAttr, mesh + '.uExport')
            else:
                cmds.error('connectRenderMeshes>>> please specify a LOD integer (0-4) for your meshes')

        except Exception as e:
            print e
        finally:
            cmds.undoInfo(closeChunk=True) 
開發者ID:chrisevans3d,項目名稱:uExport,代碼行數:22,代碼來源:uExport.py

示例8: connectRoot

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def connectRoot(self, uNode, root, rewire=1):
        try:
            cmds.undoInfo(openChunk=True)
            if rewire:
                conns = cmds.listConnections(uNode + '.export_root', plugs=1, source=1)
                if conns:
                    for conn in conns:
                        cmds.disconnectAttr(conn, uNode + '.export_root')

            if not attrExists(root+'.export'):
                cmds.addAttr(root, longName='export', attributeType='message')
            cmds.connectAttr(root + '.export', uNode + '.export_root' )
        except Exception as e:
            print e
        finally:
            cmds.undoInfo(closeChunk=True) 
開發者ID:chrisevans3d,項目名稱:uExport,代碼行數:18,代碼來源:uExport.py

示例9: __create_fk

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def __create_fk(self):
        ik_switch = cmds.listConnections(
            "{}.ikBlend".format(self.two_bone_ik.ik_handle), d=False, plugs=True
        )[0]
        for ikh in [self.ik_handle_ball, self.ik_handle_toe]:
            cmds.connectAttr(ik_switch, "{}.ikBlend".format(ikh))
        self.ball_fk_ctrl = cmds.createNode(
            "transform", name="{}_fk_ctrl".format(self.ball_joint)
        )
        common.snap_to(self.ball_fk_ctrl, self.ball_joint)
        common.lock_and_hide(self.ball_fk_ctrl, "sv")
        cmds.parent(self.ball_fk_ctrl, self.two_bone_ik.end_fk_control)
        common.freeze_to_parent_offset(self.ball_fk_ctrl)
        ori = cmds.orientConstraint(self.ball_fk_ctrl, self.ball_joint)[0]
        cmds.connectAttr(
            "{}.ikFk".format(self.two_bone_ik.config_control),
            "{}.{}W0".format(ori, self.ball_fk_ctrl),
        ) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:20,代碼來源:leg.py

示例10: _set_from_curve

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def _set_from_curve(self, transform):
        """Store the parameters from an existing curve in the CurveShape object.

        :param transform: Transform
        """
        shape = shortcuts.get_shape(transform)
        if shape and cmds.nodeType(shape) == "nurbsCurve":
            create_attr = "{}.create".format(shape)
            connection = cmds.listConnections(create_attr, plugs=True, d=False)
            if connection:
                cmds.disconnectAttr(connection[0], create_attr)
            self.transform = transform
            self.cvs = cmds.getAttr("{}.cv[*]".format(shape))
            self.degree = cmds.getAttr("{}.degree".format(shape))
            self.form = cmds.getAttr("{}.form".format(shape))
            self.knots = get_knots(shape)
            if cmds.getAttr("{}.overrideEnabled".format(shape)):
                if cmds.getAttr("{}.overrideRGBColors".format(shape)):
                    self.color = cmds.getAttr("{}.overrideColorRGB".format(shape))[0]
                else:
                    self.color = cmds.getAttr("{}.overrideColor".format(shape))
            else:
                self.color = None
            if connection:
                cmds.connectAttr(connection[0], create_attr) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:27,代碼來源:control.py

示例11: input_transform

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def input_transform(self, i):
        """Get the input transform at index

        :param i: Index
        :return: The transform driving the input at index i
        """
        input_count = cmds.getAttr("{}.inputQuatCount".format(self.name))
        if i >= input_count:
            raise RuntimeError("Invalid input index")
        # Traverse connections to the transform
        # inputQuat <- decomposeMatrix <- transform
        connection = cmds.listConnections(
            "{}.inputQuat[{}]".format(self.name, i), d=False
        )

        if not connection or cmds.nodeType(connection[0]) != "decomposeMatrix":
            return None
        connection = cmds.listConnections(
            "{}.inputMatrix".format(connection[0]), d=False
        )
        return connection[0] if connection else None 
開發者ID:chadmv,項目名稱:cmt,代碼行數:23,代碼來源:rbf.py

示例12: zero_weights

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def zero_weights(blendshape):
    """Disconnects all connections to blendshape target weights and zero's
     out the weights.

    :param blendshape: Blendshape node name
    :return: Dictionary of connections dict[target] = connection
    """
    connections = {}
    targets = get_target_list(blendshape)
    for t in targets:
        plug = "{}.{}".format(blendshape, t)
        connection = cmds.listConnections(plug, plugs=True, d=False)
        if connection:
            connections[t] = connection[0]
            cmds.disconnectAttr(connection[0], plug)
        cmds.setAttr(plug, 0)
    return connections 
開發者ID:chadmv,項目名稱:cmt,代碼行數:19,代碼來源:blendshape.py

示例13: pivot_driver_attr

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def pivot_driver_attr(node):
    '''
    Start with supporting pivots driven by remap value nodes, more support in the future as requested.
    '''
    #rpSrc = mc.listConnections(node+'.rotatePivot', source=True, destination=False, plugs=True)
    #if rpSrc and rpSrc[0].endswith('.translate') and mc.getAttr(rpSrc[0], keyable=True):
        #return rpSrc[0]

    for each in ('rotatePivotX', 'rotatePivotY', 'rotatePivotZ'):
        src = mc.listConnections(node+'.'+each, source=True, destination=False)
        if not src:
            continue
        srcType = mc.nodeType(src[0])
        if srcType == 'remapValue':
            src = mc.listConnections(src[0]+'.inputValue', source=True, destination=False, plugs=True)
            if src and mc.getAttr(src[0], keyable=True) and not mc.getAttr(src[0], lock=True):
                return src[0]
    return None 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:20,代碼來源:ml_pivot.py

示例14: selected

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def selected(*args):

    curves = mc.keyframe(query=True, selected=True, name=True)
    if not curves:
        return

    try:
        mc.delete(ATTR_FILTER_NAME)
    except:pass
    try:
        mc.delete(OBJ_FILTER_NAME)
    except:pass

    filters = list()
    for c in curves:
        plug = mc.listConnections(c, plugs=True, source=False, destination=True)[0]
        print plug
        filters.append(mc.itemFilter(byName=plug, classification='user'))

    print filters
    selectedFilter = mc.itemFilter(union=filters)
    #mc.delete(filters)
    print selectedFilter
    mc.outlinerEditor('graphEditor1OutlineEd', edit=True, attrFilter=selectedFilter) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:26,代碼來源:ml_graphEditorMask.py

示例15: getRootAndCOM

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listConnections [as 別名]
def getRootAndCOM(node):
    '''
    Given either the root or COM, return root and COM based on connections.
    '''

    com = None
    root = None

    if mc.attributeQuery(COM_ATTR, node=node, exists=True):
        com = node
        messageCon = mc.listConnections(com+'.'+COM_ATTR, source=True, destination=False)
        if not messageCon:
            raise RuntimeError('Could not determine root from COM, please select root and run again.')
        root = messageCon[0]
    else:
        messageCon = mc.listConnections(node+'.message', source=False, destination=True, plugs=True)
        if messageCon:
            for each in messageCon:
                eachNode, attr = each.rsplit('.',1)
                if attr == COM_ATTR:
                    com = eachNode
                    root = node
                    break

    return root, com 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:27,代碼來源:ml_centerOfMass.py


注:本文中的maya.cmds.listConnections方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。