inputGeom and MDagPath


#1

Hello !

 I'm trying to get the dagPath from the inputGeometry of my deformer node.
 so I can get all my points in worldSpace via MitGeometry.
 
 So far I have:
MArrayDataHandle h_outputData = data.outputArrayValue(input, &status);
        status = h_outputData.jumpToElement(geomIndex);
        MObject o_outputGeom = h_outputData.outputValue().child(inputGeom).asMesh();
    
         MFnDagNode dagNode(o_outputGeom, &status);
         CHECK_MSTATUS_AND_RETURN_IT(status);
         MDagPath path;
         status = dagNode.getPath(path);
         CHECK_MSTATUS_AND_RETURN_IT(status);

but it returns this error when creating the MFnDagNode : (kInvalidParameter): Object is incompatible with this method

so I tried this :

MSelectionList outMeshList;
       MDagPath outMeshDagPath;
       
       status = outMeshList.add(o_outputGeom);
       CHECK_MSTATUS_AND_RETURN_IT(status);
       outMeshList.getDagPath(0, outMeshDagPath);
       outMeshDagPath.isValid(&status);
       CHECK_MSTATUS_AND_RETURN_IT(status);

but again, I have an error when adding the MObject to the MSelectionList. (kInvalidParameter): Object is incompatible with this method

Any idea ?


#2

Are you sure that your connected node is a dag node and not only a dg node? E.g. if I apply a deformer to a geometry, a tweak node is created automatically what results in a:

RuntimeError: (kInvalidParameter): Object is incompatible with this method.

If you use a mesh shape node, I get a correct path (at least with python and maya api).


#3

Hello Hagi !

when I create my deformer, I specify the shape node.


  outputGeometryShape = cmds.listRelatives(outputGeometry, shapes=True)[0]
  deformerNode = cmds.deformer(outputGeometryShape, type="pmiWrap")[0]

is that what you mean by mesh shape node ?
if yes, it still creates a tweak node.

when you say “connected node”, are you refering to the mesh shape node ?

Thanks !


#4

Well, no one know why I can’t access the MDagPath from any of my mesh MObjects ?


#5

You request mesh data from the input. But a mesh does not necessarily is connected to a dag node. What is the case in the deformer node. You request meshDatas from the inputGeometry what can be used by MFnMesh to access the mesh infos. But the mesh data are not directly connected to a mesh dag node.

If you have your own deformer node, you could add a matrix attribute and connect the matrix output of your transform node to the deformer to get the transformation matrix, or simply create a message attribute and connect it. This way you can request the input and get a dag node.


#6

For now that’s what I ve done, I connected the matrix directly to my node…
But I don’ t see how a message attribute could help me getting the dagPath, could you develop a bit please ?

Thanks for your answers !


#7

You have several ways to get the data you need. One way is to create a matrix attribute and connect the transforms matrix to it. Another way could be to create a message attribute and from within your deformer, you can check the inputs and get the connected node. Then you can derive any data from the connected node.

But if you already have created a matrix attribute, everything is fine and you should be able to get the world space coordinates of your points.