How to remove Duplicate Curves in Grasshopper

Hello everyone.

Today I was trying to Project bunch of curves onto the other list of them and I faced with some duplicate lines as result.
I know that kangaroo has a component which removes duplicate lines (Not curve). Does anyone have a solution for Removing duplicate curves?2018-04-16%2013_30_54-Grasshopper%20-%20unnamed

Visit here.

2 Likes

Here is code that is doing this with curves (uses RhinoCommon for Rhino 5).


FindDuplicateCurvesA.gh (712.5 KB)

If you use Rhino 6, then there is method in RhonoCommon, GeometryEquals which may help you to write your own component for checking curves (generally any geometry) for equality.

6 Likes

Thanks .That is very helpful.

This is a very useful tool I downloaded it but what if the curves lie on each other but are different lengths, this tool doesn’t seem to work for that.
Any suggestion appreciated.
Thanks
Joe v.

Try this

curves overlap.gh (11.3 KB)

1 Like

Hi Radovan!

This is an awesome script, it performs as promised! However, it goes a little further too, it completely eliminates all duplicates (including any original curves it compares the duplicates to), to the point that none are left from those I am trying to remove only the duplicates. I am trying to retain only one version of the curves representing the edges of all boxes. See image.

Anyone able to help? Thanks!

Hi Francesco

Here is updated script that extracts one of duplicate curve from each of duplicate-curves-group …


FindDuplicateCurvesA2.gh (712.8 KB)

4 Likes

Thank you! Will give it a try!

Hi @RadovanG ,

I want to thank you for the great script you made, it’s a lot faster compare to other similar component.

Just a few wishes,

  1. When the input curves come in as tree (instead of flatten), is it possible to have CurveGroups output maintain its original data structure? Like the attach images shown, I put in a collection of curves and the eliminate result went wrong.

  2. Likewise for indices, maintain data structure of those can be used for culling purpose.

Thanks again for the great script!

Test file:
test duplicate curves.gh (383.1 KB)


My code only uses the basic functions of gh.

1 Like

I would think, that Curves can have the same bounding box center even if they are not the same

Well, in that case, you may raplace that part with curve middle, but that component does not always work.

Actually, when I started to write this code, I used curve middle, but sometimes even if the same coordinates are displayed, they cannot be classified into the same category.

What about removing overlapping curves of different lengths that are overlapping? have somebody a better solution that this: Splitting or Dividing a curve using points on that curve ?

This is extremely helpful for me. Thank you!