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


Python core.listRelatives方法代碼示例

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


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

示例1: createCurveInfoNode

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def createCurveInfoNode(crv):
    """Create and connect a curveInfo node.

    Arguments:
        crv (dagNode): The curve.

    Returns:
        pyNode: the newly created node.

    >>> crv_node = nod.createCurveInfoNode(self.slv_crv)

    """
    node = pm.createNode("curveInfo")

    shape = pm.listRelatives(crv, shapes=True)[0]

    pm.connectAttr(shape + ".local", node + ".inputCurve")

    return node


# TODO: update using plusMinusAverage node 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:24,代碼來源:node.py

示例2: setup_stretchy_spline_ik_curve

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def setup_stretchy_spline_ik_curve(cls):
        """
        """
        selection = pm.ls(sl=1)
        curve = selection[0]
        curve_info = pm.createNode("curveInfo")
        mult_div = pm.createNode("multiplyDivide")
        curve_shape = pm.listRelatives(curve, s=1)

        curve_shape[0].worldSpace >> curve_info.ic
        curve_info.arcLength >> mult_div.input1X

        curve_length = curve_info.arcLength.get()
        mult_div.input2X.set(curve_length)
        mult_div.operation.set(2)
        pm.select(mult_div, curve_info, curve_shape[0], add=True) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:18,代碼來源:rigging.py

示例3: init_hierarchy

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def init_hierarchy(self):
        """Initialize the hierarchy joints from start_joint to the given end_joint

        :return:
        """
        self.joints = [self.start_joint]
        found_end_joint = False
        for j in reversed(self.start_joint.listRelatives(ad=1, type=pm.nt.Joint)):
            self.joints.append(j)
            if j == self.end_joint:
                found_end_joint = True
                break

        if not found_end_joint:
            raise RuntimeError(
                "Cannot reach end joint (%s) from start joint (%s)" %
                (self.end_joint, self.start_joint)
            ) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:20,代碼來源:rigging.py

示例4: duplicate

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def duplicate(self, class_=None, prefix="", suffix=""):
        """duplicates itself and returns a new joint hierarchy

        :param class_: The class of the created JointHierarchy. Default value
          is JointHierarchy
        :param prefix: Prefix for newly created joints
        :param suffix: Suffix for newly created joints
        """
        if class_ is None:
            class_ = self.__class__

        new_start_joint = pm.duplicate(self.start_joint)[0]
        all_hierarchy = list(reversed(new_start_joint.listRelatives(ad=1, type=pm.nt.Joint)))
        new_end_joint = all_hierarchy[len(self.joints) - 2]

        # delete anything below
        pm.delete(new_end_joint.listRelatives(ad=1))

        new_hierarchy = class_(start_joint=new_start_joint, end_joint=new_end_joint)
        for j, nj in zip(self.joints, new_hierarchy.joints):
            nj.rename("{prefix}{joint}{suffix}".format(prefix=prefix, suffix=suffix, joint=j.name()))

        return new_hierarchy 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:25,代碼來源:rigging.py

示例5: create_local_parent

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def create_local_parent(self):
        """creates local parent and axial correction group of local parent
        """
        # create the localParent group
        self._local_parent = pm.group(
            em=True,
            n=self._object.name() + "_local_parent"
        )

        # move it to the same place where constrainedParent is
        matrix = pm.xform(self._constrained_parent, q=True, ws=True, m=True)
        pm.xform(self._local_parent, ws=True, m=matrix)

        # parent it to the constrained parents parent
        parents = pm.listRelatives(self._constrained_parent, p=True)

        if len(parents) != 0:
            temp = pm.parent(self._local_parent, parents[0], a=True)
            self._local_parent = temp[0]

        self._local_parent = pm.nodetypes.DagNode(self._local_parent)
        index = self._object.attr('pickedData.createdNodes').numElements()
        self._local_parent.attr('message') >> \
            self._object.attr('pickedData.createdNodes[' + str(index) + ']') 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:26,代碼來源:picker.py

示例6: getJointsInChain

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def getJointsInChain(rootJoint):
    """
    get all the joints in the joint chain. sorted by hierarchy.
    :param rootJoint: `PyNode` root joint of the joint chain
    :return: `list` list of joint nodes
    """
    joints = [rootJoint]
    crtJnt = rootJoint
    while True:
        childJnt = pm.listRelatives(crtJnt, c=1, typ="joint")
        if childJnt:
            joints.append(childJnt[0])
            crtJnt = childJnt[0]
        else:
            break
    return joints 
開發者ID:raina-wu,項目名稱:DynRigBuilder,代碼行數:18,代碼來源:rigutils.py

示例7: alignmentParentList

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def alignmentParentList(parentList):
    #親子順にリストを整理
    alignedList = []
    for node in parentList:
        #子のノードを取得※順序がルート→孫→子の順番なので注意、いったんルートなしで取得
        #children = common.get_children(node,type=['transform'], root_includes=False)
        children = pm.listRelatives(node, ad=True, type='transform', f=True)
        #末尾にルートを追加
        children.append(node)
        #逆順にして親→子→孫順に整列
        children.reverse()
        #同一ツリー內マルチ選択時の重複回避のためフラグで管理
        for child in children:
            appendedFlag = False
            for alignedNode in alignedList :
                if alignedNode == child:
                    appendedFlag = True
            if appendedFlag is False:
                alignedList.append(str(child))
    return alignedList 
開發者ID:ShikouYamaue,項目名稱:SIWeightEditor,代碼行數:22,代碼來源:symmetrize.py

示例8: findRotatedBones

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def findRotatedBones(joints=None):
    '''
    Checks joints (defaulting to the )
    '''

    if not joints:
        obj = core.findNode.getRoot()
        joints = listRelatives(obj, ad=True, type='joint')

    rotated = []

    for j in joints:
        if not core.math.isClose( j.r.get(), [0, 0, 0] ):
            rotated.append( (j, j.r.get()) )

    #print '{0} rotated of {1} tested'.format(len(rotated), len(joints) )
    
    return rotated


# -----------------------------------------------------------------------------
# SimpleLog is useful for other deeply nested things reporting errors.  This might
# be the better way to do things in general. 
開發者ID:patcorwin,項目名稱:fossil,代碼行數:25,代碼來源:log.py

示例9: getRootNode

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def getRootNode():
    """Returns the root node from a selected node

    Returns:
        PyNode: The root top node
    """

    root = None

    current = pm.ls(sl=True)
    if not current:
        raise RuntimeError("You need to select at least one rig node")

    if pm.objExists("{}.is_rig".format(current[0])):
        root = current[0]
    else:
        holder = current[0]
        while pm.listRelatives(holder, parent=True) and not root:
            if pm.objExists("{}.is_rig".format(holder)):
                root = holder
            else:
                holder = pm.listRelatives(holder, parent=True)[0]

    if not root:
        raise RuntimeError("Couldn't find root node from your selection")

    return root 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:29,代碼來源:anim_utils.py

示例10: bBoxData

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def bBoxData(obj=None, yZero=False, *args):
    """Get bounding box data of a mesh object

    Arguments:
        obj (dagNode): Mesh object
        yZero (bool): If True, sets the Y axis value to 0 in world space
        args:

    Returns:
        list: center, radio, bounding box full data

    """
    volCenter = False

    if not obj:
        obj = pm.selected()[0]
    shapes = pm.listRelatives(obj, ad=True, s=True)
    if shapes:
        bb = pm.polyEvaluate(shapes, b=True)
        volCenter = [(axis[0] + axis[1]) / 2 for axis in bb]
        if yZero:
            volCenter[1] = bb[1][0]
        radio = max([bb[0][1] - bb[0][0], bb[2][1] - bb[2][0]]) / 1.7

    return volCenter, radio, bb


#################################################
# CLOSEST LOCATIONS
################################################# 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:32,代碼來源:meshNavigation.py

示例11: export_blend_connections

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def export_blend_connections():
    """Exports the connection commands from selected objects to the blendShape
    of another object. The resulted text file contains all the MEL scripts to
    reconnect the objects to the blendShape node. So after exporting the
    connection commands you can export the blendShape targets as another maya
    file and delete them from the scene, thus your scene gets lite and loads
    much more quickly.
    """
    selection_list = pm.ls(tr=1, sl=1, l=1)

    dialog_return = pm.fileDialog2(cap="Save As", fm=0, ff='Text Files(*.txt)')

    filename = dialog_return[0]
    print(filename)

    print("\n\nFiles written:\n--------------------------------------------\n")

    with open(filename, 'w') as fileId:
        for i in range(0, len(selection_list)):
            shapes = pm.listRelatives(selection_list[i], s=True, f=True)

            main_shape = ""
            for j in range(0, len(shapes)):
                if pm.getAttr(shapes[j] + '.intermediateObject') == 0:
                    main_shape = shapes
                    break
            if main_shape == "":
                main_shape = shapes[0]

            con = pm.listConnections(main_shape, t="blendShape", c=1, s=1, p=1)

            cmd = "connectAttr -f %s.worldMesh[0] %s;" % (
                ''.join(map(str, main_shape)),
                ''.join(map(str, con[0].name()))
            )
            print("%s\n" % cmd)
            fileId.write("%s\n" % cmd)

    print("\n------------------------------------------------------\n")
    print("filename: %s     ...done\n" % filename) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:42,代碼來源:auxiliary.py

示例12: create_axial_correction_group_for_clusters

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def create_axial_correction_group_for_clusters(cls):
        selection = pm.ls(sl=1)
        Rigging.axial_correction_group()
        pm.select(cl=1)
        for cluster_handle in selection:
            cluster_handle_shape = pm.listRelatives(cluster_handle, s=True)
            cluster_parent = pm.listRelatives(cluster_handle, p=True)
            trans = cluster_handle_shape[0].origin.get()
            cluster_parent[0].translate.set(trans[0], trans[1], trans[2])
        pm.select(selection) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:12,代碼來源:rigging.py

示例13: add_controller_shape

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def add_controller_shape(cls):
        selection = pm.ls(sl=1)
        if len(selection) < 2:
            return
        objects = []
        for i in range(0, (len(selection) - 1)):
            objects.append(selection[i])
        joints = selection[len(selection) - 1]
        for i in range(0, len(objects)):
            parents = pm.listRelatives(objects[i], p=True)
            if len(parents) > 0:
                temp_list = pm.parent(objects[i], w=1)
                objects[i] = temp_list[0]
            temp_list = pm.parent(objects[i], joints)
            objects[i] = temp_list[0]
            pm.makeIdentity(objects[i], apply=True, t=1, r=1, s=1, n=0)
            temp_list = pm.parent(objects[i], w=True)
            objects[i] = temp_list[0]
        shapes = pm.listRelatives(objects, s=True, pa=True)
        for i in range(0, len(shapes)):
            temp_list = pm.parent(shapes[i], joints, r=True, s=True)
            shapes[i] = temp_list[0]
        joint_shapes = pm.listRelatives(joints, s=True, pa=True)
        for i in range(0, len(joint_shapes)):
            name = "%sShape%f" % (joints, (i + 1))
            temp = ''.join(name.split('|', 1))
            pm.rename(joint_shapes[i], temp)
        pm.delete(objects)
        pm.select(joints) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:31,代碼來源:rigging.py

示例14: jointUnder

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def jointUnder(self, joint):
        jointUnder = pm.listRelatives(joint, c=1, type="joint")
        if not len(jointUnder):
            pm.setAttr(joint.jointOrient, (0, 0, 0))
            return None
        return jointUnder 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:8,代碼來源:joint.py

示例15: duplicateJointChain

# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import listRelatives [as 別名]
def duplicateJointChain(rootJoint, replace=None, suffix=None):
    """
    Duplicate the given joint chain.
    :param rootJoint: `PyNode` root joint of the given joint chain
    :param replace: `tuple` or `list` (old string, new string)
                    rename the duplicated joint chain by replacing string in given joint name
    :param suffix: `string` rename the duplicated joint chain by adding suffix to the given joint name
    :return: `list` list of joints in the duplicated joint chain. ordered by hierarchy
    """
    srcJnts = getJointsInChain(rootJoint)
    dupJnts = []
    if not replace and not suffix:
        raise ValueError("Please rename the duplicated joint chain.")
    for i, srcJnt in enumerate(srcJnts):
        newName = srcJnt.name()
        if replace:
            newName = newName.replace(replace[0], replace[1])
        if suffix:
            newName = "{0}_{1}".format(newName, suffix)
        dupJnt = pm.duplicate(srcJnt, n=newName, po=1)[0]
        dupJnts.append(dupJnt)
        for attr in ['t', 'r', 's', 'jointOrient']:
            pm.setAttr("{0}.{1}".format(dupJnt.name(), attr), pm.getAttr("{0}.{1}".format(srcJnt.name(), attr)))
        if i>0:
            dupJnt.setParent(dupJnts[i-1])
    #
    # for i, srcJnt in enumerate(srcJnts):
    #     if i==0: continue
    #     srcPar = pm.listRelatives(srcJnt, p=1)
    #     if srcPar:
    #         dupJnts[i].setParent(srcPar[0].name().replace(replace[0], replace[1]))
    return dupJnts 
開發者ID:raina-wu,項目名稱:DynRigBuilder,代碼行數:34,代碼來源:rigutils.py


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