Python API: Getting dagPath from inputGeom mesh data

35 views
Skip to first unread message

Nazmi Yazıcı

unread,
Sep 14, 2020, 8:49:52 AM9/14/20
to Python Programming for Autodesk Maya

Hi, i'm trying to write a collision deformer and when i try to ray cast with MFnMesh.closestIntersection() i'm getting the error below because i need the points in worldSpace:

"Must have a DAG path to do world space transforms #"

inputGet = ommpx.cvar.MPxGeometryFilter_input
inputHandle = dataBlock.outputArrayValue(inputGet) inputHandle.jumpToElement(geoIndex)
inputElement = inputHandle.outputValue()
inputGeomGet = ommpx.cvar.MPxGeometryFilter_inputGeom
inputGeom = inputElement.child(inputGeomGet).asMesh()
defMeshFN = om.MFnMesh(inputGeom)

I'm not getting any error with this, i can attach a function set to inputGeom but i can't use the dagPath or getPath methods. Those methods giving me the "Object does not exist" or 'not being compatible' error.

I can get the collider dagPath using MPlug because it's a custom attribute on the node. I tried the same with outputGeom plug and some GeometryFilter methods but they result in cycle. It's frustrating, any help is highly appreciated!

vince touache

unread,
Sep 14, 2020, 10:00:52 AM9/14/20
to Python Programming for Autodesk Maya
hello,

not sure my approach is the right one, but I usually try to avoid working with full dag paths in a deformer, as I prefer to keep every node independent from the others (beside inputs connections ofc).
If you want to get the dag path, you can use the static method MDagPath::getAPathTo().
But instead of doing that, couldn't you use the localToWorldMatrix provided to you by Maya in the deform() method? It will require a little bit more math, but give a more robust result to get your world position

Nazmi Yazıcı

unread,
Sep 14, 2020, 10:32:28 AM9/14/20
to Python Programming for Autodesk Maya
getAPathTo method gives " Object is incompatible with this method" error. I was dealing with this for like 4 days, just after i posted here your idea came to my mind. I'll try that tomorrow, i think it's just multiplication of the MPoint and localToWorldMatrix, is that correct?

14 Eylül 2020 Pazartesi tarihinde saat 17:00:52 UTC+3 itibarıyla vince touache şunları yazdı:
Reply all
Reply to author
Forward
0 new messages