Remove lines or curves from output

I have a list of curves that I want to check their intersections.

If I feed the curves into the python I get an output of points and lines.

So I thought it’d be a good idea to convert the curves into lines so I can remove the lines easily … but,
if intersection_point in curves
doesn’t seem to work…

So now I’m trying to only add Autodesk.DesignScript.Geometry.Point to my list… But I get the error:
NameError: name ‘Object’ is not defined

What am I doing wrong / any other solutions.

I want my output to be only points.

Well this works… but I’d like to know how to do it ‘properly’

@Alien ,

for sorting out is my favourite GroupByKey or GroupByFunction

in Python there is

that works bretty well

KR

Andreas

2 Likes

Hi @Alien ,

You can use List.RemoveIfNot to remove anything that isnt a Point. To find out what exactly to input you can use Object.Type to get its type.

3 Likes

Here’s one possible way using itertools.combinations
EDIT Coincident lines return a line :person_facepalming:

import clr
from itertools import combinations

clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import Point

def intersect(lns):
    """ lns: pair of Dynamo lines
    returns intersection point or None"""
    result = lns[0].Intersect(lns[1])
    if result and isinstance(result[0], Point):  # Only Points
        return result[0]

lines = IN[0]

output = []

for group in lines:
    line_combination_pairs = combinations(group, 2)
    intersection_points = map(intersect, line_combination_pairs)
    filtered_list = filter(None, intersection_points)
    output.append(filtered_list)
        
OUT = output