Geometry intersect not finding intersections

Hi … what have I missed?
(Happy New Year!)
The DWG has 3dpoly’s that intersect nested block entities.
Need to get the intersection points, where the poly’s cross the nested entities.
I used pull-on-to-plane to ensure that all Z values are the same - zero.
Why do I not get intersection points?
Thx for your patience…
Kevin.

intersect2d.dwg (1.2 MB)
projected-2d-intersect.dyn (36.9 KB)

oops! blush
the block has transformation properties … I missed this …

trans

intersect2d-00.dwg (1.2 MB)
Nope … still no intersection points (block ref transform not taken into consideration)

I returned to basics to check … luckily all segments are line segments …
… can get intersections using X and Y of Line lists instead of PolyCurve to represent 3dpolys …
… the problem is Geometry.Intersect … not sure how to use it correctly with PolyCurves

projected-2d-intXY.dyn (49.3 KB)

import sys
import clr

clr.AddReference('AutoCADNodes')
clr.AddReference('Civil3DNodes')   
clr.AddReference('Autodesk.Civil3DToolkit')  
import Autodesk.AutoCAD.DynamoNodes as DA  
import Autodesk.Civil.DynamoNodes as DC 

from Autodesk.DesignScript.Geometry import *

def line_intersection(a, b, c, d):
    t = ((a[0] - c[0]) * (c[1] - d[1]) - (a[1] - c[1]) * (c[0] - d[0])) / ((a[0] - b[0]) * (c[1] - d[1]) - (a[1] - b[1]) * (c[0] - d[0]))
    u = ((a[0] - c[0]) * (a[1] - b[1]) - (a[1] - c[1]) * (a[0] - b[0])) / ((a[0] - b[0]) * (c[1] - d[1]) - (a[1] - b[1]) * (c[0] - d[0]))

    # check if line actually intersect
    if (0 <= t and t <= 1 and 0 <= u and u <= 1):
        return [a[0] + t * (b[0] - a[0]), a[1] + t * (b[1] - a[1])]
    else: 
        return False


set1 = IN[0]
set2 = IN[1]
res = []

for e1 in set1:
    i = False
    for c1 in e1:
        c1s = c1.StartPoint
        c1e = c1.EndPoint
        L1 = [[c1s.X,c1s.Y],[c1e.X,c1e.Y]]
        i = False
        for e2 in set2:
            for c2 in e2:
                c2s = c2.StartPoint
                c2e = c2.EndPoint
                L2 = [[c2s.X,c2s.Y],[c2e.X,c2e.Y]]
                i = line_intersection(L1[0],L1[1],L2[0],L2[1])
                if i:
                    break
            if i:
                break
        if i:
            break
    res.append(i)
    
OUT = res

Solved! : )

Don’t use the Geometry.Intersect Node … use script instead …

import sys
import clr

from Autodesk.DesignScript.Geometry import *

set1 = IN[0]
set2 = IN[1]

res = []

for e1 in set1:
    i = False
    for c1 in e1:
        for e2 in set2:
            for c2 in e2:
                i = Geometry.Intersect(c1,c2)
                if i:
                    break
            if i:
                break
        if i:
            break
    res.append(i)
    
OUT = res