Project Points to Breps with knowing which Breps got hit

Hi, I’m writing a customized forward ray-tracing script, the workflow includes using Rhino.Geometry.Intersect.Intersection.ProjectPointsToBreps() to find the projected points, and then use Rhino.Geometry.Brep.ClosestPoint() to find the normal vector of each projected point. To do this, I have to enumerate through all existing Breps for all points to see if there is a matching on-Brep point. Which pushed the working load to Rhino’s limit and it gets a chance to crash. The question is, If I can know exactly which Brep got the projection with the ProjectPointsToBreps method, then I don’t have to go through the entire Brep list. I know that there is an Ex version of ProjectPointsToBreps method but it only returns the indices of the original points. Are there any other methods exist that I can directly get the idex of projected brep inside the Brep list?

Hi Danny,

How about using RayShoot for finding and handling intersections?

It will return a RayShootEvent that gives you the point3d, brep index, and it’s face index

Hi Willem, thank you for your reply.
Actually I chose to use this project method after using RayShoot for several times. As I found RayShoot will ignore the Brep Trims and lead to wrong ray paths (I have a curved building envelop made with trimmed surfaces).
For mesh it has similar problems if the mesh cannot be welded, then if the ray hit near the ‘crack’, the ray path will have a chance to accidentally go behind the mesh.
Besides, RayShoot is rather a packaged method, but I wish to do some customized operations at each reflection. For example, stop the ray-tracing when the reflected energy is lower than a threshold.
But still, thank you very much for replying.