Ray to surface

Im trying to replicate the look of a Lidar point cloud in rhino python and have (sorta) succeeded by drawing a line from a point enclosed within a solid and running an intersection command to get a point on the surface. The problem is that I have to draw a line that is much larger than the enclosing surface and trim it back. Is there a way to draw a line UNTIL it hits a surface?

thanks in advance

Well, if you have a direction vector - which can be gotten in a number of ways - then you can simply use

rhinoscriptsyntax.ProjectPointToSurface (3dPoint, surface_id, direction_vector)

That should give you a point on the surface, you can then construct your line from the original point and the projected point.

HTH, --Mitch

1 Like

Note that rhinoscriptsyntax.ProjectPointToSurface returns a list of points.
If the list contains more than 1 point you will have to test which is closest to ‘you’.


if it is return a point list, try this:

def pointclose(point, point_list):
ds_min =min([point.DistanceTo(i) for i in point_list])
for i in point_list:
ds = point.DistanceTo(i)
if ds == ds_min:
return i

thanks! I haven’t gotten around to trying it yet but I’ll post results when I do.