Grasshopper

algorithmic modeling for Rhino

Just in case someone really needs a quick script to remove duplicate items, here it is in VB.net. This component has a single input of X that is a List( Of On3dPoint ) and output A. You should be able to change the type and it will still work.



Dim uniquePoints As New List( Of On3dPoint )
Dim found As Boolean = False
Dim i As Double = 0
Dim j As Double = 0
For i = 0 To x.Count - 1 Step 1
Dim cPoint As On3dPoint = x.Item(i)
found = False
If uniquePoints.Contains(cPoint) Then
found = True
End If
If found = False Then
uniquePoints.Add(cPoint)
End If
Next

A = uniquePoints


Hope it helps someone!

Views: 3696

Replies to This Discussion

if it is points / lines, check out kangaroo...
funny, I have that installed and I never saw that bit of it... oh well

that was the start to a script I wrote to eliminate points that are inside a circle with 5 other points, essentially finding the points inside circles containing less than 6 points
Thank you! That it is necessary.
thanks, ti's useful
Oh I would be careful using list.contains on geometrical inputs. Try moving one of the points in your list 0.00000000001 units (basically a rounding error) and watch as it is included in the new list of unique points.

Ben

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service