Delete lines that intersect a plane

Hi, I’m trying to add a function to the below script that creates lines from one point to all other points in my 3d scene. The function is to not create lines, or delete lines, that intersect a plane. Or even a new code that deletes lines that intersect any plane in my scene. Any ideas? Here’s the script I have for the lines from a point.

import rhinoscriptsyntax as rs

def createLines():
    point1 = rs.GetObject("Select the first point", 1, preselect=True)
    p1 = rs.coerce3dpoint(point1)
    if point1:
        other_points = rs.ObjectsByType(1)
        for id in other_points:
            if id != point1:
                    rs.AddLine(p1, rs.coerce3dpoint(id))


Now, I’m trying to add the function of either:
once created, delete those lines that intersect with the planes in my model
if id != point1:
AND if path doesnt intersect planes

Let me know if I need to be more clear.

Not sure how many points, lines and planes you have, but this can get expensive fast.

I also assume by plane you mean a surface/brep?

I think you will probably have to drop down to rhinocommon to do the intersection test for speed (not adding to document) and I don’t see an rs method for line/curve brep intersection.

This is a slow but direct example. I invented lines and ‘planes’:

import Rhino as R
import rhinoscriptsyntax as rs
import scriptcontext as sc

# all lines start from origin
origin = R.Geometry.Point3d.Origin

# manually made and jittered some 'planes', which are breps
plane_guids = rs.GetObjects('select planes')

# manually made a point cloud on a sphere to use as end points for lines
target_guid = rs.GetObject('select target point cloud')

# make a list of lines from origin to each point cloud item
# lines have to be a LineCurve type for intersection test
lines = []
for pci in rs.coercegeometry(target_guid):
    lines.append(R.Geometry.LineCurve(origin, pci.Location))
# intersect each line with each plane (really a brep)
# if it intersects then add it to a list
intersecting_lines = []
for guid in plane_guids:
    plane = rs.coercegeometry(guid)
    for line in lines:
        # the intersection test returns a two things.
        # we are interested in the t_array, or an array(list) of t parameters where the line intersects the brep
        test_ok, t_array = R.Geometry.Intersect.Intersection.CurveBrep(line, plane, sc.doc.ModelAbsoluteTolerance, sc.doc.ModelAngleToleranceRadians)
        if len(t_array) > 0:
            # we know there is at least one intersection t point
# now go through the lines
for line in lines:
    # if the line is not an intersecting line then add it to the document
    if line not in intersecting_lines:

This is the result:

It is slow but maybe it will help get you started.