Check to see if lines are coincident

I’m writing a Python script and need to check to see if a set of input lines is coincident with the edge of a wall. The input lines may be different lengths than the wall edges (larger or shorter) or may only overlap slightly. Any idea of a concise way to check for this?

Hi Bo,

have you tried evaluating the two lines’ intersection ? If the result’s a line, then the two are coincident:


1 Like

Another possible approach…

This workflow would also include any line that might begin at the start or end point and extend in the opposite direction.
Dimitar’s suggestion is the way to go if such lines need to be filtered out.

Any tips on making this a relatively compact Python script?

import clr
from Autodesk.DesignScript.Geometry import *

l1 = IN[0]
l2 = IN[1]

def co_check(a,b):
    try : x = a.Intersect(b)[0]
    except : x = None
    return x is not None and \
           'Line' in str(type(x) )
OUT = co_check(l1,l2)


Thanks Dimitar. Super helpful.