‘’‘
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
def line_brep_intersection(line, brep):
# find the intersection between the line and the Brep
intersection_events = rs.CurveBrepIntersect(line, brep, tolerance=0.001)
# check if there are any intersection points
if intersection_events is not None:
if intersection_events[0] is not None:
intersection_pt = intersection_events[1][0] # return the first intersection pt
else:
# there are no intersections, extend the line and check for intersections again
brep = [brep]
extended_line = rs.ExtendCurve( line, 0, 1, brep)
# check if there are any extension line
if extended_line is not None:
brep = brep[0]
intersection_events = rs.CurveBrepIntersect(extended_line, brep, tolerance=0.001)
# check if extension line has any intersection points with brep
if intersection_events is not None:
if intersection_events[0] is not None:
intersection_pt = intersection_events[1][0] # return the first intersection pt
else:
intersection_pt = rg.Point3d.Unset # return the first intersection pt
else:
intersection_pt = rg.Point3d.Unset # assign an empty value to intersection pt
else:
intersection_pt = rg.Point3d.Unset # assign an empty value to intersection pt
return intersection_pt
Define input lines
center = [50, 0, 0]
end_pt = [50, 0, 50]
line = rs.AddLine(center, end_pt)