algorithmic modeling for Rhino

I made a little VBscript that remove duplicate values from a single list of numbers. It's not optimized but it works. Use it, test it and letme know. As usual, hints ad upgrades are welcome. Bye.


Views: 6544


Reply to This

Replies to This Discussion

cool, thank you!

Hi Paolo,


see attached. It's a bit smaller (and I think quite a bit faster, especially on large lists). I added comments to the code, but here it is without:


Dim lut As New SortedDictionary(Of Double, Boolean)       

Dim result As New List(Of Double)      

For Each value As Double In Values            

    If (lut.ContainsKey(value)) Then Continue For            


    lut.Add(value, True)


A = result



David Rutten

Poprad, Slovakia




what to do for string duplicates?

Dim lut As New SortedDictionary(Of String, Boolean)

Dim result As New List(Of String)  

You can use any type you want as long as it provides it's own CompareTo method. If it doesn't, then you'll have to provide the SortedDictionary with a custom delegate which performs the comparison.


David Rutten

Poprad, Slovakia


How do I remove string doubles in the example below?

I tried to change the script according to your instructions in italics, but i can not get it to work. I dont know a thing about VB so i did not understand your further instructions. My String is too long to be converted to number.

Any help would be greatly appreciated. 


Ok, so this was not as difficult as i had presumed. No need for scripting.

If anyone else ever goes crawling through these old posts - know that you can use the standard components below to delete (most) text duplicates without the use of scripts.


Hi Ludvig, just creating a Set and sort its results works too:

Mind blown, i thought sets could only handle numerical values. This certainly helps. Thanks!


How change the code for Breps?



You don't want to use a dictionary for comparing breps, as there are too many aspects to compare. Some aspects are geometrical, others are topological. Do you want to treat two breps that have the same shape as identical? Even if their face and edge counts differ?

Writing a brep/brep comparer will almost certainly have to take into account tolerances and different edge/vertex/face orderings. It's a difficult task, especially if you want to do it quickly, but you can start with this:

  1. (geometric aspect) Compare the bounding-boxes. If they are not identical within tolerance, the breps are not the same.
  2. (topological aspect) Compare the face counts of both breps. If they differ, the breps are not the same.
  3. (topological aspect) Compare the edge counts of both breps. If they differ, the breps are not the same.
  4. (topological aspect) Compare the vertex counts of both breps. If they differ, the breps are not the same.
  5. (geometric aspect) Measure the distance from all the vertices in Brep A to the nearest vertex in Brep B. If two vertices are further apart than your tolerance, the breps are not the same.
  6. ...
  7. ...
  8. ...

There are hundreds of rules you could come up with and it really depends on what you consider to be 'identical'.

A completely different approach (which only tests geometric equality) is to randomly generate a point on Brep A, then find the closest point on Brep B. If the distance > tolarance the breps are not identical. Then generate a random point on Brep A and measure distance to closest point on Brep A. Repeat several hundred times for medium certainty. Repeat several thousand times for high certainty.

Thank you David for the quick reply.

I got it but probably my problem is easier to solve:

I have multiple breps with same geometry and topology.

Initially, I found useful to use VB component (as in the post before) but it's just set for double value and because of my lack of experience I cannot modify the script.



Are they really the same breps, or are they different breps that just happen to be identical?





© 2018   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service