I run into an issue, I created a compound array attribute with two children, an int array and mesh data attributes.
I copied here the part of the code, removed the unnecessary parts. I create a deformer and I connect the driver mesh into the “driverMesh” attribute.
The error I got this: # RuntimeError: (kFailure): Object does not exist //
@note: I found on internet other solutions to pull the data through plugs (it didn’t work either). Because of performance I try to use only DataBlock to pull the mesh data and avoid reading the plugs.
This is from memory, but I think you can only get the name when MFnMesh is wrapping an actual mesh node in the DAG, instead of just mesh data which is what you have. Do other methods of fnDriverMesh work?
Right, but the MFnMesh object you have created is wrapping the mesh data (oDriverMesh) which is different than the DAG node that is connected to the driverMesh attribute.
“This function set provides access to polygonal meshes. Objects of type MFn::kMesh, MFn::kMeshData, and MFn::kMeshGeom are supported. MFn::kMesh objects are shapes in the DAG, MFn::kMeshGeom objects are the raw geometry that the shapes use, and MFn::kMeshData objects are the data that is passed through dependency graph connections”
So oDriverMesh is of type MFn::kMeshData - it’s not the DAG node that is connected to the driverMesh attribute.
If you need the DAG node that is connected to the attribute, use something like this (I didn’t actually run this, so there may be errors)
Right, but the MFnMesh object you have created is wrapping the mesh data (oDriverMesh) which is different than the DAG node that is connected to the driverMesh attribute.
That was the key. Now I solved my first idea also. I passed the mesh data, not the actual object and it worked!
hDrivers = data.inputArrayValue(MyDeformer.aDrivers)
for driverIdx in range(hDrivers.elementCount()):
status = hDrivers.jumpToElement(driverIdx)
if status:
builder = hDrivers.builder()
builder.addElement(driverIdx)
hDrivers.setBuilder(builder)
hDrivers.jumpToElement(driverIdx)
hDriver = hDrivers.inputValue()
hDriverMesh = hDriver.child(VertexSnap.aDriverMesh)
geoIt = OpenMaya.MItGeometry(hDriverMesh)
print geoIt.count() # Result: 121