Identifying Duplicate Curves between 2 lists

Hello everyone,
I’m trying to solve what would seem like a straightforward problem but can’t seem to get it to work. I’m trying to find duplicates between 2 lists of curves. The first list is made of subdivided smaller lines while the second list is made of joined polylines. I need to identify curves that aren’t duplicates and add them to a separate list. I think the logic is pretty straight forward:

For every curve in list A, get end points, find closest point in list B, if distances>0, add them to another list

#ID PROJECTED CURVES
#FOR EVERY CURVE IN A, GET END POINTS, FIND CRVCLOSEST POINT IN B, IF T0 + T1 = 0, CULL

        def IDprojectedCurves(curves1, curves2):
        a = []
        b = []
        totalDist = 0                                       #START VALUE OF TOTAL DIST
        maxDist = 0                                         #START VALUE OF MAX DIST

        for x in curves1:                                   #ADD CURVES1 TO LIST A
            a.append(x)

        for y in curves2:                                   #ITERATE LIST OF LISTS [FLATTEN INTO 1 LIST]
            for j in y:
                b.append(j)

        for crvA in a:                                          #FOR EACH CURVE IN A
            crv = rs.coercecurve(crvA)              
            t00 = rs.CurveStartPoint(crv)                       #START POINT
            t05 = rs.CurveMidPoint(crv)                         #MID POINT
            t10 = rs.CurveEndPoint(crv)                         #END POINT
            rs.AddPoint(t00)
            rs.AddPoint(t05)
            rs.AddPoint(t10)

            for crvB in b:                                          #FOR EACH CURVE IN B
                dist0 = rs.CurveClosestPoint(crvB,t00)              #FIND CLOSEST POINT IN CURVE B
                dist1 = rs.CurveClosestPoint(crvB,t10)              #FIND CLOSEST POINT IN CURVE B
                dist2 = rs.CurveClosestPoint(crvB,t05)              #FIND CLOSEST POINT IN CURVE B
                totalDist = dist0+dist1+dist2                       #ADD DISTANCES AND SAVE TO TOTAL DIST
                if totalDist > maxDist:                             #IF TOTAL DIST > MAX DIST
                    totalDist = maxDist                             #   TOTAL DIST = MAX DIST
                else:
                    maxDist = maxDist                               #ELSE MAX DIST = MAX DIST
            if maxDist>0:                                       #IF MAX DIST>0
                projected = crv                             
                projectedCurves.append(projected)               #ADD TO PROJECTED CURVES LIST

For some reason, the values of totalDist & MaxDist never change from 0 so the condition is never met. Im not sure where I’m going wrong. If anyone has any ideas or suggestions on what I’m doing wrong, I would be very grateful.

Gracias

Below is how I would do it. It looks at physical intersection, so it might take longer than other methods.

import rhinoscriptsyntax as rs

lines = rs.GetObjects("Select lines")
polylines = rs.GetObjects("Select polylines")
safeList = []

if lines and polylines:
    for line in lines:
        overlap = None
        for polyline in polylines:
            if overlap == None:
                intersections = rs.CurveCurveIntersection(line, polyline)
                if intersections != None:
                    for intersection in intersections:
                        if intersection[0] == 2:
                            overlap = True
                            break
        if overlap == None:
            safeList.append(line)

rs.SelectObjects(safeList)

The lines are the sub-elements you want check if they overlap with the polylines.