Line - trimmed surface intersection with python

hi, I am trying to get the intersection of a series of lines to a few surfaces (see example and image attached). However these surfaces have been trimmed, when I check for the intersection I get also the intersections to the trimmed part of the surface. Is there a way to get only the intersections to the actual visible surface?

import rhinoscriptsyntax as rs
srfs = rs.GetObjects(“srfs”,8)
lines = rs.GetObjects(“lines”,4)
rs.EnableRedraw(False)
rs.AddLayer(“spheres”)
rs.AddLayer(“text”)
for srf in srfs:

for line in lines:
    
    intersect1 = rs.CurveSurfaceIntersection(line, srf)
    
    if intersect1 is not None:
        pt1 = intersect1[0][1]
        rs.AddPoint(pt1)

question on intersection.3dm (75.0 KB)

Hi @revink

  1. shrink the srf
  2. use curvebrep intersection

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.intersect.intersection/curvebrep

Alternative Rhinoscriptsyntax :

import rhinoscriptsyntax as rs

srfs = rs.GetObjects("Select surfaces", 8)
lines = rs.GetObjects("Select lines", 4)

rs.EnableRedraw(False)
rs.AddLayer("spheres")
rs.AddLayer("text")

for srf in srfs:
    for line in lines:
        # Use CurveBrepIntersect instead of CurveSurfaceIntersection
        intersect = rs.CurveBrepIntersect(line, srf)
        

rs.EnableRedraw(True)

Hope this helps,

Farouk