一半君的总结纸

听话只听一半君

How to list all upstream nodes using Maya Python API ?

来自以下网址:

3dtechart.com/test/api
Get skincluster data with maya’s python API
introduction-to-the-maya-api
Using_the_Maya_Python_API
edit:我后来发现好几个地方都有:
mayamel.tiddlyspot.com
外加自己改了下

def getAllDGNodes(inNode,direction,nodeMfnType):
    '''
    direction : om.MItDependencyGraph.kUpstream
    nodeMfnType : om.MFn.kAnimCurve
    '''
    import maya.OpenMaya as om

    nodes = []
    # Create a MSelectionList with our selected items:
    selList = om.MSelectionList()
    selList.add(inNode)
    mObject = om.MObject()  # The current object
    selList.getDependNode( 0, mObject )

    # Create a dependency graph iterator for our current object:
    mItDependencyGraph = om.MItDependencyGraph(mObject,direction,om.MItDependencyGraph.kPlugLevel)
    while not mItDependencyGraph.isDone():
        currentItem = mItDependencyGraph.currentItem()
        dependNodeFunc = om.MFnDependencyNode(currentItem)
        # See if the current item is an animCurve:
        if currentItem.hasFn(nodeMfnType):
            name = dependNodeFunc.name()
            nodes.append(name)
        mItDependencyGraph.next()

    # See what we found:
    for n in sorted(nodes):
        print n

    return nodes

直接listHistory也可以

import maya.cmds as cmds
cmds.ls(*cmds.listHistory (mynode), type = 'animCurve' )

# 如果controller有shape,那就得直接查询transform attr
cmds.ls(*cmds.listHistory (mynode+'.t'), type = 'animCurve' )
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: