algorithmic modeling for Rhino
Tags:
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
result.Add(value)
lut.Add(value, True)
Next
A = result
--
David Rutten
david@mcneel.com
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
david@mcneel.com
Poprad, Slovakia
Hi!
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.
Mind blown, i thought sets could only handle numerical values. This certainly helps. Thanks!
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:
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.
Cheers,
Piero
Are they really the same breps, or are they different breps that just happen to be identical?
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by