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
Here’s one possible way using itertools.combinations EDIT Coincident lines return a line
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