My only thoughts would be to convert the polycurves to verticies with pretty tight spacing and then creating a closed curve by using a minimum distance between points, lines between points, and closing them into a curve, kind of similar to how the code works in the popular “groupCurves” function works in archi-lab:
#join/group curves function
def groupCurves(Line_List):
ignore_distance = 0.1 # Assume points this close or closer to each other are touching
Grouped_Lines = []
Queue = set()
while Line_List:
Shape = []
Queue.add(Line_List.pop()) # Move a line from the Line_List to our queue
while Queue:
Current_Line = Queue.pop()
Shape.append(Current_Line)
for Potential_Match in Line_List:
Points = (Potential_Match.StartPoint, Potential_Match.EndPoint)
for P1 in Points:
for P2 in (Current_Line.StartPoint, Current_Line.EndPoint):
distance = P1.DistanceTo(P2)
if distance <= ignore_distance:
Queue.add(Potential_Match)
Line_List = [item for item in Line_List if item not in Queue]
Grouped_Lines.append(Shape)
return Grouped_Lines
OUT = groupCurves(inputCurves)
Creating code that would create a best fit hatch without a closed curve is a difficult thing to do. But probably possible. It looks like you can set a gap tolerance directly in AutoCAD.
This Mesh Toolkit looks really promising. I may try playing with it to see if it can provide a solution.
Dynamo Mesh Toolkit