Grasshopper

algorithmic modeling for Rhino

delete overlapping lines from a list (not just the duplicates)

Hi guys,

i would like to get rid of overlapping lines in a list of lines:

I know there is a "delete duplicate lines" in Kangaroo but it only deletes one of the duplicate not both lines that overlap.

I want to delete both overlapping lines....

Hope that makes sense.

thanks a lot,

arthur

Views: 5114

Replies to This Discussion

Couldn't you sort the lines based on length, then test for duplicate lengths to create a cull pattern?

Scripting the test routine might be easiest.
Thanks taz but isn't that only going to delete the duplicate lines and not the ones below it too?
I ll try it
Well if you have a sorted list and a value matches a previous value, then you'd add them both to the list of items to remove.

Without actually putting it together, I think this approach would work as long as all your lines aren't the same length.
Hi taz how would you "test for duplicate length"?
If I had to do it real quick I would use this other definition I posted here:

valCount

Thanks Taz,

not sure I got it...

Could you please say a bit more about how this script works?

 

Dim i As Integer

Dim j As Integer = 1
Dim count As New List(Of Double)

Dim valCount As New List(Of Double)
data.Sort()

data.Add(0)
For i = 1 To data.Count() - 1
If data(i) - data(i - 1) = 0 Then
j = j + 1
Else
count.Add(data(i - 1))
valCount.Add(j)        j = 1
End If
Next
vals = count    numVals = valCount

 

Many thanks,

 

Arthur

I hope you haven't been pondering for 8 months...  It's been so long I couldn't do this from scratch again if I tried.

 

Basically the routine is just a counter that works on sorted integers.  If the following value matches the current value the counter is incremented by 1.

 

If this is not the case the current count value is add to a list and reset to 1 (the counter starting value).  There's a separate list for the unique integers.

 

The code is pretty sparse with a single For loop and an If statement so I'm not sure if I can add much else...

 

Hope that helps a bit.

Hey Taz!

Thanks a lot, it does help.

 

Being a bit short on time I think I ended up using the "delete overlapping lines" in Kangaroo.

 

I was still wondering how to check for duplicate data in a list and use the resulting pattern in a dispatch component.

 

Would you know how to make a script which would output a true for unique values and a false for any repeating values?

 

Cheers,

 

Arthur

That's the exact application shown in the April 11 image above.

 

I couldn't script all that with the grafting and stuff, but I'm sure it wouldn't be too hard (for someone else...) to wrap it all up in a script.

 

Are you trying to make a user module?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service