Group PolyCurves by Distance, but only according to their start- and endpoints

Hello everyone,

I am working on a script which gets (2D) Civil3D Blocks into Dynamo to turn them into 3D Civil3D Objects. The problem which i am facing right now is that PolyCurves which intersect with other PolyCurves which are already Closed, see image below:

This wouldnt be a problem if i could just Close the Blue Polycurve, except i cant do that because i have other Objects in my file which look like this: (As you can see the Surface is wrong)

I think the solution here lies with the fact that in the first screenshot the lines are not connecting at their start- or endpoints but they are at the second image. But i dont know how to group Curves only by their start- and endpoints

I hope i was clear enough, and that someone knows a good way to approach this :slight_smile:


Complex Road Marking Script V4 04-12-2020.dyn (33.5 KB)
RoadmarkingDWG.dwg (892.9 KB)

Try a group curves node from Archi-lab. It may not load in C3D but last I checked it was a custom node which means you can copy / paste the contents D4R to add the code to your graph, save the graph, and open it in C3D to get the good stuff.

1 Like

Okay thanks for the tip, i’ll try that!
Ps: what does D4R mean?

Hi Jacob,

I tried to do the thing that you said but i am getting this error:

I don’t know how to solve/ approach this because i don’t know a lot about Python.

The Script:

#Copyright(c) 2015, Konrad Sobon
# @arch_laboratory,

import clr
from Autodesk.DesignScript.Geometry import *

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

inputCurves = IN[0]

#join/grou    p curves function
    def groupCurves(Line_List): 
    	ignore_distance = 0.01 # 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() 
    			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: 
    			Line_List = [item for item in Line_List if item not in Queue]
    	return Grouped_Lines

    OUT = groupCurves(inputCurves)

I Think the error has to do with the fact that i am feeding nested lists into this Python script.
But i dont know how to change this script to also accept nested lists

Wrap it in a new custom node perhaps? How much do you need this to scale?

1 Like

Hi @jacob.small,

Yeah i did that and now it works as expected!
Thanks for the help!!