Grasshopper

algorithmic modeling for Rhino

hi,

can anyone give me a hint how to delete identical elements in a list (remaining just one of them)?

For example cleaning up the HexGrid.Point output so that I don't have all the vertice points on top of each other, but just a pointgrid with single points.

thanks a lot!

J

Views: 329

Replies to This Discussion

A not very elegant workaround is to use a script like this. Input in 'x' the point list and set it as 'list':

Dim ptlist As New list(Of On3dPoint)
For i As Integer = 0 To x.Count - 1
Dim bol As Boolean = True
For j As Integer = i + 1 To x.Count - 1
If round((x(i).x * 10 ^ 8 + x(i).y * 10 ^ 4 + x(i).z), 2) = round((x(j).x * 10 ^ 8 + x(j).y * 10 ^ 4 + x(j).z), 2) Then bol = False
Next
If bol Then ptlist.add(x(i))
Next
a = ptlist

I think someone posted a more appropiate way of doing it, similar to how the "seldup" command works. You can also run the seldup command in a script using app.RunScript("-seldup"), but its a bit messy since you have to bake the geometry first and select the resulting geometry all within the script.
thanks Vicente!
Rather than doing a bunch of rounding and math, it might just be easier to do an equal to comparison since this operator is supported by the On3dPoint class. Not only will this work when comparing points, but it will should work for comparing vectors, planes, and also intervals.

If x(i) = x(j) Then bol = False
The problem is that rounding is still necessary, and you can't round x(i) directly, you'd have to round x(i).x, x(i).y and x(i).z independently.
When you connect a point to a number parameter a numeric value is given. I'm guessing this value is unique for the point position? What does it represent? I'm sure there's a more elegant way that multiplying each number by gazillions and adding them together to get a unique id.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service