python类listHistory()的实例源码

skinio.py 文件源码 项目:cmt 作者: chadmv 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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, basestring):
        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))
zbw_rig.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_deformers(obj, *args):
    """
    gets a list of deformers on the passed obj
    :param obj: string - the transform to get deformers on
    :param args:
    :return:
    """
    history = cmds.listHistory(obj)
    deformerList = []
    if history:
        for node in history:
            types = cmds.nodeType(node, inherited=True)
            if "geometryFilter" in types:
                deformerList.append(types[1])

    return(deformerList)
ml_utilities.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
utils.py 文件源码 项目:mayakit 作者: danbradham 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_history(node, node_type=None):

    history = cmds.listHistory(node)
    if not node_type:
        return history

    return [n for n in history if cmds.nodeType(n) == node_type]
zbw_deformerWeights.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def getDeformers(obj):
    """take in an xform"""
    defs = []
    history = cmds.listHistory(obj) or []
    defHist = cmds.ls(history, type="geometryFilter", long=True)
    for d in defHist:
        if d not in ["tweak1"]:
            defs.append(d)
    return(defs)
ml_resetBind.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
ml_centerOfMass.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
ml_copySkin.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def getSkinCluster(mesh):

    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
maya_tools.py 文件源码 项目:gozbruh 作者: LumaPictures 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _get_gozid_mismatches(objs):
    """Return objects from `objs` whose gozbruhBrushID does not match their name

    Checks object history for instances of gozbruhBrushID,
    returns a list ofgozbruhBrushID/name conflicts

    gozbruhBrushID is created by ZBrush on export and is used to track
    name changes that can occur in maya

    this function compares object current name against the ID
    and returns a list of conflicts

    this list is handled by the gui to allow for dialog boxes
    """
    goz_list = []

    for obj in objs:
        has_attr = cmds.attributeQuery(
            'gozbruhBrushID', node=obj, exists=True)

        if has_attr:
            # check for 'rename'
            goz_id = cmds.getAttr(obj + '.gozbruhBrushID')
            if obj != goz_id:
                goz_list.append((obj, goz_id))
        else:
            # check for old ID in history
            for old_obj in cmds.listHistory(obj):
                has_attr = cmds.attributeQuery('gozbruhBrushID',
                                               node=old_obj,
                                               exists=True)
                if has_attr:
                    goz_id = cmds.getAttr(old_obj + '.gozbruhBrushID')
                    if obj != goz_id:
                        goz_list.append((obj, goz_id))

    # resulting mismatches to be handled
    return goz_list

#------------------------------------------------------------------------------
# Sending / Exporting
#------------------------------------------------------------------------------
ml_centerOfMass.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def createCenterOfMass(*args):
    '''
    Create a center of mass node, and constrain it to the 
    character based on the selected root node.
    '''

    sel = mc.ls(sl=True)

    if not len(sel) == 1:
        raise RuntimeError('Please select the root control of your puppet.')

    print 'Create Center Of Mass Node'
    print '--------------------------'

    meshes = meshesFromReference(sel[0]) or meshesFromHistory(sel[0])

    if not meshes:
        raise RuntimeError('Could not determine geomerty from selected control. Make sure geo is visible.')

    mc.select(meshes)
    mc.refresh()

    print 'Discovered Meshes:'
    for mesh in meshes:
        print '\t',mesh

    skinnedMeshes = []
    for mesh in meshes:
        if utl.getSkinCluster(mesh):
            skinnedMeshes.append(mesh)
            continue
        hist = mc.listHistory(mesh, breadthFirst=True)
        skins = mc.ls(hist, type='skinCluster')
        if not skins:
            warnings.warn('Could not find a skinned mesh affecting {}'.format(mesh))
            continue
        outGeo = mc.listConnections(skins[0]+'.outputGeometry[0]', source=False)
        outGeo = mc.ls(outGeo, type=['mesh','transform'])
        if not outGeo:
            warnings.warn('Could not find a skinned mesh affecting {}'.format(mesh))
            continue
        skinnedMeshes.append(outGeo[0])

    if not skinnedMeshes:
        raise RuntimeError('Could not determine skinned geometry from selected control. This tool will only work if geo is skinned.')

    locator = centerOfMassLocator(skinnedMeshes)

    mc.addAttr(locator, longName=COM_ATTR, attributeType='message')
    mc.connectAttr('.'.join((sel[0],'message')), '.'.join((locator,COM_ATTR)))

    mc.select(sel)
    return locator


问题


面经


文章

微信
公众号

扫码关注公众号