Curve intersection

Hello, I’m working on a script and I need help. I want to be able to create intersection points on curves that are not flat, in this case at different heights.

import rhinoscriptsyntax as rs

def project_lines_to_objects():
    objects = rs.GetObjects("Curve", rs.filter.curve)
    if not objects:
        return

    while True:
        curva_desenhada = rs.GetLine()
        if not curva_desenhada:
            break  
        rs.EnableRedraw(False)
        p1, p2 = curva_desenhada
        linha_desenhada = rs.AddLine(p1, p2)
        if not linha_desenhada:
            continue 

        for obj in objects: 
            projected_points = []

            if rs.IsCurve(obj):
                intersections = rs.CurveCurveIntersection(linha_desenhada, obj)
                if intersections:
                    for intersection in intersections:
                        if intersection[0] == 1: 
                            pt = intersection[1]
                            projected_points.append(rs.AddPoint(pt))

        rs.DeleteObject(linha_desenhada)
        rs.EnableRedraw(True)

project_lines_to_objects()

Only the middle one and the square might possibly have intersections. And even then, the curve might just be above the square,