So here's the solution I got working i believe:
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.")
The trick is that I needed to pass the shape node and to only use OpenMaya.MItDependencyGraph.kPlugLevel). In this example it finds the base object of the blendshape.