Grasshopper

algorithmic modeling for Rhino

Is there an easy way to filter out duplicate numbers in a list?

So there is "1,1,0,2,4,4,4,3,4,2,0" and output would be only "0,1,2,3,4".

What would be even better is if there is a way to also remove duplicate objects in a list, or objects with the same geometry, is that possible?

Much appreciated.

Theunis

Views: 36974

Replies to This Discussion

I know this tread is inactive but i thought i might share something of the topic. This script in addition to gh components splits a list of points(or anything else) to a list of twins(identical objects) and a list of remaining objects. It has no limit to the amount of identical objects and the index is remained. This may contain flaws, but hopefully it could be of use.

  Private Sub RunScript(ByVal points As List(Of Object), ByVal y As Object, ByRef A As Object)
    Dim twins As New List(Of Integer)
    For i As Integer = 0 To points.Count - 1
      For b As Integer = i + 1 To points.Count - 1
        If points(i) = points(b)Then
          twins.Add(i)
          twins.Add(b)
          'Im not sure this is a good way to go but it worked for me
        End If
      Next
    Next
    A = twins
  End Sub

/filip

Attachments:

Awesome!

This component cant remove same floating numbers when you not use sort list component.

There is one very quick way for numbers..feed the numbers into x-input of 'construct point component'; then 'cull duplicate points'; then 'deconstruct point' and get back the numbers from x-output, without any duplicates

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service