[Maya] Is there a way to separate a model which intersect with another model?

I have a scene with tree branches and leaves.
Each tree branch is a mesh and all leaves is one mesh.


What I want to do is get leaves which intersect with one branch and separate it.

I know I can do that through Max vol. select with crossing mesh object, an the result I want is like this

I am wondering if there is a way to do this in Maya, since I want to write a script for that, I cannot just use my eyes and hand select leaves I want.

For now I thinking I may just separate all leaves into different meshes and trying to find those who is intersect/crossing with the branch and then combine it back. It’s a dumb way>"<
Maybe someone have a good way to do that in Maya?

Thanks >"<

Shortly, you have to use Maya API or Maya Python Api to find all intersections between two objects using MFnMesh.anyIntersections. It returns faceIDs which are intersected with another mesh and then you have to select shells and separate those shells which include those faces. It’s not the case where you can use only MEL. Use C++

1 Like