Get the surrounding elements from the same family


I have a generic annotation family it has been copied multiple times on the same plan my goal is to find the closest (more then one) to first one in a list, then find the closest to the second one in the list and so on.
The search area is depending on his position.

for 1 i need only 2 and 4 (yellow)
for 3 i need 2,4,5 and 6 (red)
for 5 i need 3 and 6. (blue)
for 6 i need 2, 3 and 5

Tool.GetSurroundingElements does not work with the same family

has any one an idea to get it done.

Thnxs EdwinInheiniveaulaag sonderingen2.dyn (57.7 KB)

Get the families. Get thier location. Geometry.DistanceTo with lacing set to cross product. Use an if statement to test the length - if the distance is under the threshold add the point at that distance, otherwise null. Then clean your data of nulls. Then drop the item itself from the list of points. Could look like this though I had to randomly recreate your dataset.

1 Like


Thank you for your reply however the code blocks don’t seem to work but you helped me a lot.
I hope you can help me a little further, by setting the node to crossing i get all the results i want but i don’t know if its from 1 to 2 or 1 to 3.
element positions II

So i want to know how to get the crossing result from the “List.GetItemAtIndex” at the top right in the grey area

and so on… so this is matching with the results from Geometry.DistanceTo

Thnx Edwin.

Can you share your dyn? That code block shouldn’t have failed unless your data structure was off and that’s going to impact everything going forward…

sure here it is.
Inheiniveaulaag sonderingen2.dyn (63.7 KB)

I took another approach i now search for the nearest ones, number is given by the user and go on from here but thanks anyway.