Project overlapping curves as one?

Hi all,

I am trying to create a Grasshopper definition to optimise DXF files for laser cutting. This includes removing duplicate curves - which I do with BullAnt’s ggRemoveDuplicates successfully - but overlapping curves are a tough cookie so far.

For example: these two lines are overlapping (bottom two lines are separated duplicates)

image

I can try to figure out a method of finding overlapping curves - e.g. divide curve points and test if points are on other curves - and remove the shorest one. But since I only need the “projected image” for the laser cutting machine and not have to retain the curve data, maybe there is an easier solution:

In Photoshop there is the option to “Flatten Image” → squashing all data onto one layer.
Is there a way to create that in Grasshopper?
(I know I am comparing pixels vs vectors here, but you get the idea)

Thanks!

do you have a “good closed curve” somewhere before or after being projected, or just small/big segments?

how complex are your final shapes?

attaching a GH file with internalised geometries would help much :+1:

for instance, if you had just “simple shapes” then maybe an approach like just taking all the control points, cull duplicates, sort them along something, polyline those, get discontinuity and re-polyline just on discontinuities might work (meaning I have used that before)

Hi Inno,

Thanks for your suggestions.

The GH file will be used to “clean up” DXF files provided by students, so shapes and complexity can vary a lot.

So I wanted to create an algorithm to “merge overlapping lines” based on a very simple example first (two straight lines) and then optimise to accommodate more complex shapes.
Two different sized rectangles with the same origin is an often occuring ‘shape’ by students, with overlapping lines (as attached).

I have tried your method on the two-rectangle example (not sure if I did correctly though) but due to oddly sorted control points the orginal shape is not produced.

After writing my initial post, I tried another method: Divide curves by distance (e.g. 0.1) , so there are duplicate chunks which can be eliminated and then joined. This works when the lines are within a tollerance of 0.1 of each other.

In terms of optimisation, I am now trying to identify where overlapping lines occur (so only on these lines above method needs to be applied to) as well as identifying within tollerence lines to be fixed.

DivideOverlappingLines.gh (12.3 KB)
TwoRectanglesOverlapping.3dm (28.3 KB)

well, in this example you have a very specific situation where all are closed curves

this is the first thing that comes to my mind: shatter everything by everything else, remove duplicates (and that should work well now because all the segments are minimal, so any overlapping can be culled) then join, and to reduce vertexes to the minimum discontinuity + polyline (but there are also dedicated components that can reduce the number of points to save components, such as Curve → Utility → Reduce)

the last Explode Curve is just to show the final number of segments per polyline in a Panel

DivideOverlappingLines_Re.gh (12.2 KB)