当前位置: 首页>>代码示例>>Python>>正文


Python cmds.listRelatives方法代码示例

本文整理汇总了Python中maya.cmds.listRelatives方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.listRelatives方法的具体用法?Python cmds.listRelatives怎么用?Python cmds.listRelatives使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.listRelatives方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: shape_from_element

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def shape_from_element(element):
    """Return shape of given 'element'

    Supports components, meshes, and surfaces

    """

    try:
        # Get either shape or transform, based on element-type
        node = cmds.ls(element, objectsOnly=True)[0]
    except:
        cmds.warning("Could not find node in %s" % element)
        return None

    if cmds.nodeType(node) == 'transform':
        try:
            return cmds.listRelatives(node, shapes=True)[0]
        except:
            cmds.warning("Could not find shape in %s" % element)
            return None

    else:
        return node 
开发者ID:getavalon,项目名称:core,代码行数:25,代码来源:util.py

示例2: dpLoadBSNode

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [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

示例3: dpIsolate

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def dpIsolate(self, attrName, nodeList, *args):
        """ Function to run isolate setup.
        """
        # get father zero out transform node
        zeroGrp = cmds.listRelatives(nodeList[2], allParents=True, type="transform")[0]
        # create parent constraint
        pConst = cmds.parentConstraint(nodeList[0], nodeList[1], zeroGrp, maintainOffset=True, skipTranslate=["x", "y", "z"])[0]
        # add isolate attribute to selected control
        cmds.addAttr(nodeList[2], longName=attrName, defaultValue=1.0, minValue=0, maxValue=1, keyable=True) 
        # create reverse node
        reverseNode = cmds.createNode('reverse', name=nodeList[2]+"_"+attrName.capitalize()+"_Rev")
        # do isolate connections
        cmds.connectAttr(nodeList[2]+"."+attrName, pConst+"."+nodeList[0]+"W0", force=True)
        cmds.connectAttr(nodeList[2]+"."+attrName, reverseNode+".inputX", force=True)
        cmds.connectAttr(reverseNode+".outputX", pConst+"."+nodeList[1]+"W1", force=True)
        cmds.select(nodeList[2]) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:18,代码来源:dpIsolate.py

示例4: renameShape

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def renameShape(self, transformList, *args):
        """Find shapes, rename them to Shapes and return the results.
        """
        resultList = []
        for transform in transformList:
            # list all children shapes:
            childShapeList = cmds.listRelatives(transform, shapes=True, children=True, fullPath=True)
            if childShapeList:
                # verify if there is only one shape and return it renamed:
                if len(childShapeList) == 1:
                    shape = cmds.rename(childShapeList[0], transform+"Shape")
                    cmds.select(clear=True)
                    resultList.append(shape)
                # else rename and return one list of renamed shapes:
                elif len(childShapeList) > 1:
                    for i, child in enumerate(childShapeList):
                        shape = cmds.rename(child, transform+str(i)+"Shape")
                        resultList.append(shape)
                    cmds.select(clear=True)
            else:
                print "There are not children shape to rename inside of:", transform
        return resultList 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:24,代码来源:dpControls.py

示例5: setSourceColorOverride

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def setSourceColorOverride(self, sourceItem, destinationList, *args):
        """ Check if there's a colorOverride for destination shapes
            and try to set it to source shapes.
        """
        colorList = []
        for item in destinationList:
            childShapeList = cmds.listRelatives(item, shapes=True, type="nurbsCurve", fullPath=True)
            if childShapeList:
                for childShape in childShapeList:
                    if cmds.getAttr(childShape+".overrideEnabled") == 1:
                        if cmds.getAttr(childShape+".overrideRGBColors") == 1:
                            colorList.append(cmds.getAttr(childShape+".overrideColorR"))
                            colorList.append(cmds.getAttr(childShape+".overrideColorG"))
                            colorList.append(cmds.getAttr(childShape+".overrideColorB"))
                            self.colorShape([sourceItem], colorList, True)
                        else:
                            colorList.append(cmds.getAttr(childShape+".overrideColor"))
                            self.colorShape([sourceItem], colorList[0])
                        break 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:21,代码来源:dpControls.py

示例6: shapeSizeSetup

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def shapeSizeSetup(self, transformNode, *args):
        """ Find shapes, create a cluster deformer to all and set the pivot to transform pivot.
            Returns the created cluster.
        """
        clusterHandle = None
        childShapeList = cmds.listRelatives(transformNode, shapes=True, children=True)
    #    print "Child length {0}".format(len(childShapeList))
        if childShapeList:
            thisNamespace = childShapeList[0].split(":")[0]
            cmds.namespace(set=thisNamespace, force=True)
            clusterName = transformNode.split(":")[1]+"_ShapeSizeCH"
            clusterHandle = cmds.cluster(childShapeList, name=clusterName)[1]
            cmds.setAttr(clusterHandle+".visibility", 0)
            cmds.xform(clusterHandle, scalePivot=(0, 0, 0), worldSpace=True)
            cmds.namespace(set=":")
        else:
            print "There are not children shape to create shapeSize setup of:", transformNode
        return clusterHandle 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:20,代码来源:dpControls.py

示例7: clearNodeGrp

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def clearNodeGrp(nodeGrpName='dpAR_GuideMirror_Grp', attrFind='guideBaseMirror', unparent=False):
    """ Check if there is any node with the attribute attrFind in the nodeGrpName and then unparent its children and delete it.
    """
    if cmds.objExists(nodeGrpName):
        foundChildrenList = []
        childrenList = cmds.listRelatives(nodeGrpName, children=True, type="transform")
        if childrenList:
            for child in childrenList:
                if cmds.objExists(child+"."+attrFind) and cmds.getAttr(child+"."+attrFind) == 1:
                    foundChildrenList.append(child)
        if len(foundChildrenList) != 0:
            if unparent:
                for item in foundChildrenList:
                    cmds.parent(item, world=True)
                cmds.delete(nodeGrpName)
        else:
            cmds.delete(nodeGrpName) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:19,代码来源:dpUtils.py

示例8: mirroredGuideFather

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def mirroredGuideFather(nodeName):
    """ This function verify if there is a mirrored guide as a father of the passed nodeName.
        Returns the mirrored guide father name if true.
    """
    parentList = cmds.listRelatives(nodeName, parent=True, type='transform')
    if parentList:
        nextLoop = True
        while nextLoop:
            if cmds.objExists(parentList[0]+".guideBase") and cmds.getAttr(parentList[0]+".guideBase") == 1 and cmds.getAttr(parentList[0]+".mirrorEnable") == 1 and cmds.getAttr(parentList[0]+".mirrorAxis") != "off":
                return parentList[0]
                nextLoop = False
            else:
                parentList = cmds.listRelatives(parentList[0], parent=True, type='transform')
                if parentList:
                    nextLoop = True
                else:
                    nextLoop = False 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:19,代码来源:dpUtils.py

示例9: createCurveShape

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def createCurveShape(name, points):
    """ 
    Create a curve and rename the shapes to be unique.

    :param str name: Name of curve
    :param list points: List of points.
    """
    # create curve
    curve = cmds.curve(p=points, d=1, n=name)

    # rename shapes
    shapes = []
    for shape in cmds.listRelatives(curve, s=True, f=True) or []:
        shape = cmds.rename(shape, "{0}Shape".format(name))
        shapes.append(shape)

    return curve, shapes 
开发者ID:robertjoosten,项目名称:maya-spline-ik,代码行数:19,代码来源:curve.py

示例10: convertToBezierCurve

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def convertToBezierCurve(curve):
    """
    Check if the parsed curve is a bezier curve, if this is not the case
    convert the curve to a bezier curve.
    
    :param str curve: Name of curve
    """
    # get shape
    curveShape = cmds.listRelatives(curve, s=True)[0]

    # convert to bezier curve
    if cmds.nodeType(curveShape) == "bezierCurve":
        return
        
    cmds.select(curve)
    cmds.nurbsCurveToBezier()


# ---------------------------------------------------------------------------- 
开发者ID:robertjoosten,项目名称:maya-spline-ik,代码行数:21,代码来源:curve.py

示例11: name_changed

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def name_changed(self, widget, name):
        """ triggered by one of the spore widgets when the user
        requests a name change
        :param widget: the source of the signal
        :param name: the new name """

        node_name = widget.long_name
        if cmds.objExists(node_name):
            if re.match('^[A-Za-z0-9_-]*$', name) and not name[0].isdigit():
                #  transform = cmds.listRelatives(node_name, p=True, f=True)[0]
                instancer = node_utils.get_instancer(node_name)
                cmds.rename(instancer, '{}Instancer'.format(name))
                cmds.rename(node_name, '{}Shape'.format(name))
                #  cmds.rename(transform, name)

            else:
                self.io.set_message('Invalid Name: Use only A-Z, a-z, 0-9, -, _', 2)
                return

        self.refresh_spore() 
开发者ID:wiremas,项目名称:spore,代码行数:22,代码来源:manager.py

示例12: context_request

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def context_request(self, widget, action):

        if action.text() == 'Delete':
            selection = cmds.ls(sl=1, typ='sporeNode')
            for geo_wdg, spore_wdgs in self.wdg_tree.iteritems():
                for spore_wdg in spore_wdgs:

                    spore_node = spore_wdg.name
                    print spore_node
                    if spore_wdg.is_selected and cmds.objExists(spore_node):
                        instancer = node_utils.get_instancer(spore_node)
                        transform = cmds.listRelatives(spore_node, p=True, f=True)

                        if len(cmds.listRelatives(transform, c=1)) == 1:
                            cmds.delete((spore_node, transform[0], instancer))
                        else:
                            cmds.delete((spore_node, instancer))

                        selection.remove(spore_node)
                        cmds.select(selection)

            self.refresh_spore() 
开发者ID:wiremas,项目名称:spore,代码行数:24,代码来源:manager.py

示例13: reset_actor

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def reset_actor():
    from . import sisidebar_sub
    sel = cmds.ls(sl=True, l=True)
    joints = cmds.ls(sl=True, l=True, type='joint')
    if not joints:
        joints = []
    for s in sel:
        if cmds.nodeType(s) == 'KTG_ModelRoot':
            child_joints = cmds.ls(cmds.listRelatives(s, ad=True, f=True), l=True, type='joint')
            if child_joints:
                joints += child_joints
    if not sel:
        joints = cmds.ls(l=True, type='joint')
    for j in joints:
        con_info = cmds.connectionInfo(j+'.bindPose', dfs=True)
        if not con_info:
            continue
        con_info = con_info[0]
        bind_info = con_info.replace('world', 'xform')
        pose = cmds.getAttr(bind_info)
        cmds.xform(j, m=pose)
    sisidebar_sub.get_matrix() 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:24,代码来源:transform.py

示例14: freeze

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def freeze():
    cmds.selectMode(o=True)
    selection = cmds.ls(sl=True, type = 'transform')
    dummy = common.TemporaryReparent().main(mode='create')#モジュールでダミーの親作成
    clusterCopy = modeling.ClusterCopy()
    for sel in selection:
        allChildren = [sel] + cmds.listRelatives(sel, ad=True)#子供を取得して1つのリストにする
        polyMesh = common.search_polygon_mesh(allChildren)
        if polyMesh:
            for mesh in polyMesh:
                common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='cut')
                defCls = clusterCopy.copy(mesh)
                cmds.bakePartialHistory(mesh,pc=True)
                if defCls:
                    clusterCopy.paste(mesh)
                common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='parent')#コピーのおわったメッシュの子供を元に戻す
    common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#ダミー親削除
    cmds.select(selection, r=True) 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:20,代码来源:freeze.py

示例15: __findChildren

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listRelatives [as 别名]
def __findChildren(node, name, firstOnly=False, partialName=False):

    if partialName:
        children = [item for item
                    in node.listRelatives(allDescendents=True,
                                          type="transform")
                    if item.name().split("|")[-1].split("_")[-1] == name]
    else:
        children = [item for item
                    in node.listRelatives(allDescendents=True,
                                          type="transform")
                    if item.name().split("|")[-1] == name]
    if not children:
        return False
    if firstOnly:
        return children[0]

    return children 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:20,代码来源:dag.py


注:本文中的maya.cmds.listRelatives方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。