RS ShootRay on trimmed srfs

Hi list,

I am trying out ShootRay() on some very simple geometry. It seems that the rays intersect the untrimmed srf, which is not what I expect.

The green points are the ray origin, red dots and connecting lines are what ShootRay() gives me as the intersection points:

If I untrim the triangular srf, it becomes obvious that the ray shooter hits trimmed-off parts of the srf:


This is on version 5SR12

Oh, and here are the model and script…

shoot_rays.3dm (62.8 KB) (314 Bytes)

Have a good weekend

Hi @axa,

unfortunately that is how it has always been and applies to vbscript, python and rhino common. The helpfile mentions:

Only Surface and Brep objects are currently supported. Trims are ignored on Breps.

Your script looks like you’re only interested in the first reflection point ? Why not intersect with a line or project the points and try to keep the closest one ? Below is an example script using projection and scene based on yours. Note that a projection can hit an object multiple times and goes in two directions… (1.8 KB)
shoot_rays.3dm (90.7 KB)


Hi Clement,

thank for pointing out the limitations of ShootRay(). I tend to work almost exclusively with the rs doclumentation

and was therefore blissfully unaware of this. With the limitations in place (no trimmed Breps, no meshes), ShootRays() is essentially useless for most tasks.

Thank you also for providing a ProjectPointsToBreps() example. Yes, for my particular application, this works very well. I’ve now re-written my code around rs.ProjectPointToSurface().

Have a good week

Any hope for this in Rhino 7 (ShootRay to work with Trimmed Breps and Mesh objects) ??

Couldn’t agree more.


Hi @Jarek,

at least for meshes you could now use Rhino.Geometry.Intersect.Intersection.MeshRay. I’ve used it for breps (their rendermesh) as well and then pulled the points to the brep if required. But i agree, a method to work around this would be great.


1 Like

Hi @clement, @Jarek, @axa,

This is still on the to-do list.

The best you can do for now is shoot a ray at a surface and then see if the first intersection point falls on face’s active region using BrepFace.IsPointOnFace.

– Dale

1 Like

It seems BrepFace.IsPointOnFace takes in a u,v parameter, so how can the point3d that is returned by shootray be turned into a u,v? Would this also mean you need to iterate through every brep object and every face of those objects that were passed to shootray as an IEnumerable?

Use BrepFace.ClosestPoint.

– Dale

Is there a way to just make a new brep that does not include the trimmed part?

unless I am missing something, if I have 1000 brep objects and do shootray, I can pass those 1000 breps, but then need to make a for loop to go over each one and use ClosestPoint, correct?

thank you

Hi @umcadop,

Generally speaking, no.

What are you trying to do, or what problem are you trying to solve? Perhaps Intersection.RayShoot isn’t the best tool for your task?

– Dale

Not exactly that, but you could mesh your Brep and use the MeshRay intersection method instead. That doesn’t do reflections though, but you could script that as well.