lections import defaultdict
example_list = [[1,2,4], [1,2,3], [3,4,3], [1,2,3], [5,7,1], [3,4,3], [5,7,1], [1,2,4], [9,4,9], [9,3,9], [9,4,9]]
d = defaultdict(list)
for item in example_list: d[tuple(item)].append(item)
groupedlist = sorted(d[x] for x in d)
print groupedlist
# Returns [[[1, 2, 3], [1, 2, 3]], [[1, 2, 4], [1, 2, 4]], [[3, 4, 3], [3, 4, 3]], [[5, 7, 1], [5, 7, 1]], [[9, 3, 9]], [[9, 4, 9], [9, 4, 9]]]
____________________________________________________
However working with python inside GH the code fails as (I'm assuming the id is included in the list ie.
[<Rhino.Geometry.Point3d object at 0x0000000000000BD0 [1611664.12669822,2952929.94466619,5788.70761766478]>]
If I print my object[0] i get just the vector, i.e [1611664.12669822,2952929.94466619,5788.70761766478]
However if i append my object, (for i in xrange (len(X)... list.append(my object[x])
The id included!?
[<Rhino.Geometry.Point3d object at 0x0000000000000BD0 [1611664.12669822,2952929.94466619,5788.70761766478]>]
Perhaps I'm over complicating this and should just use GH to group objects with the same position...
Also sometimes when getting vectors I receive long numbers such as.. 9.0122222900391e(10), and another times I don't.... Same file, script, geometry etc..
I'm quite a noobie in python for GH so any help or pointers are welcome...
Thank you in advance!
…
0009
10 = 000A
16 = 000F
65535 = FFFF
Scripting will obviously be the shortest. I think finding the shortest native def. is more interesting. Mine's 13 components including a slider for input, a panel for output, and a couple other panels to hold pertinent info (I just mean there is data that could be internalized to shave off a couple components, but there is no internalized data in mine).
Best,
Brian…
1#comments
But I seem to be having a problem with this closest to some value thing: values in my list are too small, up too 1 x 10^-30. The closest value I want to search for in that list is 1.25 x 10^-9
But Grasshoppers "find similar" component recognizes all of the values from the list, to be similar to 1.25 x 10^-9, because all of those values are in range from 0.1 to 1 x 10^-30.
Is there a way some kind of tolerance can be made, when it comes to recognizing a similar value?…
53 → 53 → 63 → 74 → 74 → 84 → 9
As you can see from the above list the connection sequence comes in waves of three, where each group of similar indices on the left is associated with a group of three incrementing indices on the right.
Some combination of Series components will probably generate this list, but it'll only work for the first ring, the second one will need a different connection pattern. It is perhaps better to just encode the integer pairs by hand. But then you cannot change your mind about the number of sides later.…
Added by David Rutten at 10:39am on October 21, 2015
(10^(-62)≤n) and (n>10^(-14))
Shouldn't this become :
10^(-4)≤n
(10^(-9)≤n) and (n<10^(-4))
(10^(-14)≤n) and (n<10^(-9))
(10^(-62)≤n) and (n<10^(-14))
…