赞
踩
所以我找到的解决方案是:def getBlendShape(shape):
'''
@param Shape: Name of the shape node.
Returns MFnBlendShapeDeformer node or None.
'''
# Create an MDagPath for our shape node:
selList = OpenMaya.MSelectionList()
selList.add(shape)
mDagPath = OpenMaya.MDagPath()
selList.getDagPath(0, mDagPath)
#Create iterator.
mItDependencyGraph = OpenMaya.MItDependencyGraph(
mDagPath.node(),
OpenMaya.MItDependencyGraph.kPlugLevel)
# Start walking through our shape node's dependency graph.
while not mItDependencyGraph.isDone():
# Get an MObject for the current item in the graph.
mObject = mItDependencyGraph.currentItem()
# It has a BlendShape.
if mObject.hasFn(OpenMaya.MFn.kBlendShape):
# return the MFnSkinCluster object for our MObject:
return OpenMayaAnim.MFnBlendShapeDeformer(mObject)
mItDependencyGraph.next()
if __name__ == '__main__':
#TargetMesh
targetMesh = "pSphereShape1"
#Get Blendshape.
blndShpNode = getBlendShape(targetMesh)
if blndShpNode:
#Get base objects.
mObjArr = OpenMaya.MObjectArray()
blndShpNode.getBaseObjects(mObjArr)
mDagPath = OpenMaya.MDagPath()
OpenMaya.MFnDagNode(mObjArr[0]).getPath(mDagPath)
print(mDagPath.fullPathName())
else:
print("No Blendshape found.")
诀窍是我需要传递形状节点并且只使用OpenMaya.MItDependencyGraph.kPlugLevel). 在本例中,它查找blendshape的基对象。在
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。