Merge overlapping/intersecting lines on same plane

Hi guys,

I am working on a workflow where i need to merge lines which are placed on the same plane.

Currently i am using the wall geometry from a linked file to identify walls which needs marked with lines, however if the wall is split in the linked file, this will result in the lines splitting aswell.

Is there an easy fix, to sort/group and then merge the lines if they are placed on the same “plane”?

As shown above, the following line consists of two separate lines which are placed relatively close - i need these to be merged into a single line.

I have tried to group, sort and filter - however nothing seems to have done the trick yet.


One method is to group all the lines which are drawn in the same direction (vector) and then use the node “Group Curves” from the Archilab package to create sub-groups of the lines which touch each other. Then you can join the lines together, recreate them as normal straight lines (instead of polycurves), and draw them in current view:

Script made with dynamo version 2.0.4: Join Touching Lines on Same Vector.dyn (95.7 KB)

Hopefully this will provide enough for you to adapt to suit your needs. There are probably some nodes out there which will automate drawing the final lines using a specific line type as I’ve just used the basic out-of-the-box node.

Note: the script does have a few nodes at the end to delete the original un-joined curves for you, so just be mindful of that.

There were some inaccurate results coming out of the standard “Vector.X”/“Vector.Y” (and even the “Point.X”/“Point.Y” variants if vector converted to point) so I used a messy object to string method to ensure accurate assessment of the line directions. Would be highly appreciated if someone from the dynamo team (@solamour) could take a look into those nodes:


Hi Andy - thanks for bringing this to our attention! We have been talking about this in the team as the display in preview bubbles of higher order operations (i.e. not just a number) is different representationally than the true number. The case here is super duper small but not quite zero. i.e. at index [4] you have a number of 0.000000000000000161687.

In the short term, you can rationalize by using the following workaround:

epsilon = 1.0e-9;
Math.Round((num + epsilon) * 100) / 100;

CC @Michael_Kirschner2 @Qilong_Tang


Hi Andy!

That almost did the trick, it did join one of set of lines which intersecting!
However, it seems to be unable to join two other sets of lines which are intersecting, i have tried to identified the lines by creating surface as shown below.

I tried to collect the start and endpoint of the lines and rounding them making sure that they would align, this however didn’t solve the issue.

Would there be any easy workflow for including these?
I have attached the mockup script here - JoinLines.dyn (167.8 KB) .

I’m not with a computer at the moment so can’t try methods for this but you could try this:

  1. Generate a plane for each line (but vertical not horizontal - i.e. an infinite extension of your extruded planes)
  2. Group your lines by those which share identical planes (note this would be more refined than the previous method to group by same vector)
  3. Get both the start and end points of the lines in each group and organise them in ascending order along the plane
  4. If there are any lines where the start/end points touch, this should create a pair of points which are identical in the list. Extract those pairs from the list to leave only the points which don’t have a ‘twin’
  5. Chop the resulting list into pairs and create lines ‘by start-end point’

Edit: this post may be useful: Planes of lines are - #9 by Ewan_Opie

Just had a chance to take a look. The ‘group by same plane’ method I suggested was a red-herring as dynamo still gives each plane a start position and other unique data/information.

Instead I used a method where every line was extended to a bounding box and trimmed so that each curve on the same axis was thus identical and could define groups for the original curves. I then proceeded with points 3 to 5 as described in my previous comment:

Note that the back green and dark red lines don’t join as they have a 20mm offset from each other. I noted you didn’t raise this as an issue in your last response, and so I didn’t add any precision rounding to force their joining.

Updated script has been annotated to clarify each process: JoinLines_v2.dyn (137.2 KB)


Using the “ꟿ Geometry.GroupByDistance” from the strings nodes seems to be able to do the trick.
This however ruins the structure of my other data which is meant to be passed on with the same structure.

I have however sorted that by using a rather raw comparing/collecting and sorting by index.

That did require a longer workflow than I anticipated, thanks a lot!
I have adopted the suggestion into my script and it seems to keep the structure and transfer all the data as required.
I have incorporated a minor rounding if walls are offset by a smaller margin :).

1 Like

Dude I love you, I working on my Architectural Final Projet to get my Bachelors Degree, and this was beautiful to use in my algorithm.