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


Python cmds.listHistory方法代碼示例

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


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

示例1: dpCheckSkinCluster

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def dpCheckSkinCluster(self, shapeList, *args):
        """ Verify if there's a skinCluster node in the list of history of the shape.
            Return True if yes.
            Return False if no.
            Return -1 if there's another node with the same name.
        """
        for shapeNode in shapeList:
            if not shapeNode.endswith("Orig"):
                try:
                    histList = cmds.listHistory(shapeNode)
                    if histList:
                        for histItem in histList:
                            if cmds.objectType(histItem) == "skinCluster":
                                return True
                except:
                    return -1
        return False 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:19,代碼來源:dpCopySkin.py

示例2: findRelatedDeltaMush

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def findRelatedDeltaMush(geometry):
    """
    Return the delta mush deformer attached to the specified geometry
    
    Args:
      geometry (str): Geometry object/transform to query
    
    Returns:
      str
    """
    # Check geometry
    if not cmds.objExists(geometry):
        raise Exception('Object '+geometry+' does not exist!')
    
    hist = cmds.listHistory(geometry, pdo=1, gl=1)
    try:
        if mayaVersion() >= 2016:
            return cmds.ls(hist, type=["deltaMush", "wbDeltaMush"])[0]
        else:
            return cmds.ls(hist, type="wbDeltaMush")[0]
    except:        
        return None

#---------------------------------------------------------------------- 
開發者ID:WebberHuang,項目名稱:DeformationLearningSolver,代碼行數:26,代碼來源:utils.py

示例3: getSkinCluster

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def getSkinCluster(mesh):
    """
    Loop over an objects history and see if a skinCluster node is part of the
    history.

    :param str mesh:
    :return: skinCluster that is attached to the parsed mesh
    :rtype: str or None
    """
    skinClusters = [
        h
        for h in cmds.listHistory(mesh) or []
        if cmds.nodeType(h) == "skinCluster"
    ]

    if skinClusters:
        return skinClusters[0] 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:19,代碼來源:skin.py

示例4: get_blendshape_node

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def get_blendshape_node(geometry):
    """Get the first blendshape node upstream from the given geometry.

    :param geometry: Name of the geometry
    :return: The blendShape node name
    """
    geometry = shortcuts.get_shape(geometry)
    history = cmds.listHistory(geometry, il=2, pdo=False) or []
    blendshapes = [
        x
        for x in history
        if cmds.nodeType(x) == "blendShape"
        and cmds.blendShape(x, q=True, g=True)[0] == geometry
    ]
    if blendshapes:
        return blendshapes[0]
    else:
        return None 
開發者ID:chadmv,項目名稱:cmt,代碼行數:20,代碼來源:blendshape.py

示例5: getSkinCluster

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def getSkinCluster(mesh):
    '''
    Return the first skinCluster affecting this mesh.
    '''

    if mc.nodeType(mesh) in ('mesh','nurbsSurface','nurbsCurve'):
        shapes = [mesh]
    else:
        shapes = mc.listRelatives(mesh, shapes=True, path=True)

    for shape in shapes:
        history = mc.listHistory(shape, groupLevels=True, pruneDagObjects=True)
        if not history:
            continue
        skins = mc.ls(history, type='skinCluster')
        if skins:
            return skins[0]
    return None 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:20,代碼來源:ml_utilities.py

示例6: dpCheckGeometry

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def dpCheckGeometry(self, item, *args):
        isGeometry = False
        if item:
            if cmds.objExists(item):
                childList = cmds.listRelatives(item, children=True)
                if childList:
                    try:
                        itemType = cmds.objectType(childList[0])
                        if itemType == "mesh" or itemType == "nurbsSurface" or itemType == "subdiv":
                            if cmds.checkBox(self.checkHistoryCB, query=True, value=True):
                                historyList = cmds.listHistory(childList[0])
                                if len(historyList) > 1:
                                    dialogReturn = cmds.confirmDialog(title=self.langDic[self.langName]["i159_historyFound"], message=self.langDic[self.langName]["i160_historyDesc"]+"\n\n"+item+"\n\n"+self.langDic[self.langName]["i161_historyMessage"], button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No')
                                    if dialogReturn == "Yes":
                                        isGeometry = True
                                else:
                                    isGeometry = True
                            else:
                                isGeometry = True
                        else:
                            mel.eval("warning \""+item+" "+self.langDic[self.langName]["i058_notGeo"]+"\";")
                    except:
                        mel.eval("warning \""+self.langDic[self.langName]["i163_sameName"]+" "+item+"\";")
                else:
                    mel.eval("warning \""+self.langDic[self.langName]["i059_selTransform"]+" "+item+" "+self.langDic[self.langName]["i060_shapePlease"]+"\";")
            else:
                mel.eval("warning \""+item+" "+self.langDic[self.langName]["i061_notExists"]+"\";")
        else:
            mel.eval("warning \""+self.langDic[self.langName]["i062_notFound"]+" "+item+"\";")
        return isGeometry 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:32,代碼來源:dpTargetMirror.py

示例7: findHistory

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def findHistory(self, objList, historyName, *args):
        """Search and return the especific history of the listed objects.
        """
        if objList:
            foundHistoryList = []
            for objName in objList:
                # find historyName in the object's history:
                histList = cmds.listHistory(objName)
                for hist in histList:
                    histType = cmds.objectType(hist)
                    if histType == historyName:
                        foundHistoryList.append(hist)
            return foundHistoryList 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:15,代碼來源:dpControls.py

示例8: store_blend_shape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def store_blend_shape(mesh):
    shapes = cmds.listRelatives(mesh, s=True, f=True)
    skin = cmds.ls(cmds.listHistory(shapes), type='skinCluster')
    if skin:
        connections = cmds.listConnections(skin, s=True, d=False)
    else:
        connections = cmds.listConnections(shapes, s=True, d=False)
    blend_shapes = cmds.ls(connections, l=True, type='blendShape')
    bs_dict = {}
    if blend_shapes:
        for bs in blend_shapes:
            shape_target = cmds.ls(cmds.listConnections(bs, s=True, d=False), l=True, type='transform')
            bs_dict[bs]=shape_target
        return bs_dict
    return 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:17,代碼來源:freeze.py

示例9: deleteZeroShape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def deleteZeroShape(node):
    meshnode = cmds.listRelatives(node, s=True, pa=True, type='mesh', fullPath=True)
    for mesh in meshnode:
        triNum = cmds.polyEvaluate(mesh, triangle=True)
        historyNode = cmds.listHistory(mesh, f=True)
        if len(historyNode) <= 1:
            cmds.delete(mesh) 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:9,代碼來源:freeze.py

示例10: save_cluster

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def save_cluster(node):
    #ノードの中からスキンクラスタを取得してくる#inMesh直上がSkinClusterとは限らないので修正
    srcDeformerCluster = cmds.ls(cmds.listHistory(node),type='cluster')
    if not srcDeformerCluster:
        return#スキンクラスタがなかったら関數抜ける
    #スキンクラスタのパラメータ色々を取得しておく
    srcDeformerCluster = srcDeformerCluster[0]
    attributes = cmds.listAttr(srcDeformerCluster)
    weightList = cmds.getAttr(srcDeformerCluster+'.weightList[0]')
    envelope = cmds.getAttr(srcDeformerCluster+'.envelope')
    clusterMssage = cmds.getAttr(srcDeformerCluster+'.message')
    clusterWeight = cmds.getAttr(srcDeformerCluster+'.weightList[0].weights') 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:14,代碼來源:freeze.py

示例11: findRelatedSkinCluster

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def findRelatedSkinCluster(geometry):
    '''
    Return the skinCluster attached to the specified geometry
    
    Args:
      geometry (str): Geometry object/transform to query
    
    Returns:
      str
    '''
    # Check geometry
    if not cmds.objExists(geometry):
        om.MGlobal.displayError('Object '+geometry+' does not exist!')
        return
    
    # Check transform
    if cmds.objectType(geometry) == 'transform':
        try: geometry = cmds.listRelatives(geometry,s=True,ni=True,pa=True)[0]
        except:
            om.MGlobal.displayError('Object %s has no deformable geometry!' % geometry)
            return

    # Determine skinCluster
    skin = mel.eval('findRelatedSkinCluster \"%s\"' % geometry)
    if not skin: 
        skin = cmds.ls(cmds.listHistory(geometry, pdo=1, gl=1), type='skinCluster')
        if skin: skin = skin[0]
    if not skin: skin = None

    # Return result
    return skin

#---------------------------------------------------------------------- 
開發者ID:WebberHuang,項目名稱:DeformationLearningSolver,代碼行數:35,代碼來源:utils.py

示例12: isBlendshape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def isBlendshape(self, mesh):
        future = cmds.listHistory(mesh, future=1)
        isShape = False
        for node in future:
            if cmds.nodeType(node) == 'blendShape':
                return True
        return False 
開發者ID:chrisevans3d,項目名稱:uExport,代碼行數:9,代碼來源:uExport.py

示例13: get_skin_clusters

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def get_skin_clusters(nodes):
    """Get the skinClusters attached to the specified node and all nodes in descendents.

    :param nodes: List of dag nodes.
    @return A list of the skinClusters in the hierarchy of the specified root node.
    """
    if isinstance(nodes, string_types):
        nodes = [nodes]
    all_skins = []
    for node in nodes:
        relatives = cmds.listRelatives(node, ad=True, path=True) or []
        relatives.insert(0, node)
        relatives = [shortcuts.get_shape(node) for node in relatives]
        for relative in relatives:
            history = cmds.listHistory(relative, pruneDagObjects=True, il=2) or []
            skins = [x for x in history if cmds.nodeType(x) == "skinCluster"]
            if skins:
                all_skins.append(skins[0])
    return list(set(all_skins)) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:21,代碼來源:skinio.py

示例14: main

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def main():

    sel = mc.ls(sl=True)

    for each in sel:
        shapes = mc.listRelatives(each, shapes=True)

        for shape in shapes:
            #get skin cluster
            history = mc.listHistory(shape, groupLevels=True, pruneDagObjects=True)
            skins = mc.ls(history, type='skinCluster')

            for skin in skins:
                joints = mc.skinCluster(skin, query=True, influence=True)

                mc.setAttr(skin+'.envelope', 0)
                mc.skinCluster(skin, edit=True, unbindKeepHistory=True)

                #delete bindPose
                dagPose = mc.dagPose(each, query=True, bindPose=True)
                if dagPose:
                    mc.delete(dagPose)
                dagPose = mc.listConnections(skin+'.bindPose', d=False, type='dagPose')
                if dagPose:
                    mc.delete(dagPose)

                mc.skinCluster(joints, shape, toSelectedBones=True)
                mc.setAttr(skin+'.envelope', 1)
    if sel:
        mc.select(sel) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:32,代碼來源:ml_resetBind.py

示例15: meshesFromHistory

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listHistory [as 別名]
def meshesFromHistory(control):
    '''
    Return all visible meshes downstream from a given control.
    '''

    #try searching backward first for speed
    meshes = []
    allMeshes = mc.ls(type='mesh')
    for mesh in allMeshes:
        hist = mc.listHistory(mesh, allConnections=True)
        if control in hist:
            if isNodeVisible(mesh):
                meshes.append(mesh)

    if meshes:
        return meshes

    #if we didn't find any, search forward from control
    #this takes a bit longer
    hier = mc.listRelatives(control, ad=True, pa=True)
    if not hier:
        hier = [control]
    else:
        hier.append(control)

    hist = mc.listHistory(hier, future=True, allFuture=True, allConnections=True)
    hist = list(set(hist))
    meshes = mc.ls(hist, type='mesh')
    meshes = [x for x in meshes if isNodeVisible(x)]

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


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