当前位置:   article > 正文

maya python api_从目标Maya Python API查找Blendshape

python与 blendshape

所以我找到的解决方案是: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的基对象。在

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/418610?site
推荐阅读
相关标签
  

闽ICP备14008679号