Python API: Getting DAG from inputGeom mesh data

Python API: Getting DAG from inputGeom mesh data

Anonymous
Not applicable
1,555 Views
2 Replies
Message 1 of 3

Python API: Getting DAG from inputGeom mesh data

Anonymous
Not applicable

Hi, i'm trying to write a collision deformer and when i try to ray cast with closestIntersection() i'm getting the error:

 

"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 in any way. Those methods giving me the "Object does not exist" or 'not being compatible' error.

 

 

 colliderInput = dataBlock.inputValue(DirectCollision.collider).asMesh()
        if colliderInput.isNull():
            return
        else:
            thisNode = om.MFnDependencyNode(self.thisMObject())
            colliderPlug = thisNode.findPlug("collider", False)
            getArray = om.MPlugArray()
            colliderPlug.connectedTo(getArray, True, False)
            colliderNode = getArray[0].node()
            colliderDAG = om.MFnDagNode(colliderNode)
            colliderDagPath = om.MDagPath()
            colliderDAG.getPath(colliderDagPath)
            colMeshFN = om.MFnMesh(colliderDagPath)

 

 

This is how i'm getting the collider dagPath using plug but couldn't figure out a way to get the dagPath of the deforming mesh with the inputGeom data.

0 Likes
1,556 Views
2 Replies
Replies (2)
Message 2 of 3

bradley_henke
Enthusiast
Enthusiast

This is a bit of a shot in the dark, but I wonder if the real problem doesn't involve the dag path, but rather the way you are accessing the input geometry data. I see you are using MDataHandle::outputArrayValue and MDataHandle::outputArray, to move around the plug tree without evaluating extra data. However, I don't see you actually calling MDataHandle::inputValue on the input mesh attribute. You still need to call inputValue on the input mesh in order for the input mesh to be evaluated and made available for you to use. Once you do this, my guess is that MFnMesh::closestIntersection will work since it will have access to the mesh data and the local to world transform.

As for the collision object, I don't think it's recommended to grab the dag path like that. For starters, you don't really know if that is the correct dag path if the node is instanced. You are calling MDataHandle::inputValue in the case of the collision object, so you should be able to use this directly with MFnMesh. The local to world matrix will be made available to MFnMesh through the MObject returned from MDataHandle::asMesh(). You can also access it via MDataHandle::geometryTransformMatrix()

0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi bradley, thanks for the input! I tried changing values to input but result is the same("

(kInvalidParameter): Must have a DAG path to do world space transforms //

"). I'm using localToWorldMatrix on the deforming object to calculate and position points in world space, it's working fine even though it's a bit hacky. I've seen some plugins that gets the inputs exactly the same way i do, use kWorld argument and no dag error so i can't figure out why is this happening to me.

 

As for the collider, i know that it's a very dirty way of getting dagPath but when i use the collider mesh input for the mesh function set, it doesn't give me an error for kWorld argument but it's far from working(5-10 vertices deform incorrectly).

0 Likes