Group Circles By Distance

Hello EveryBody,
Hope you are all Fine.
I’ve been facing a problem in wich i have to place a family that cuts a slab.
I managed to do Half of the work. As you can see in the image below, i inserted a family that cuts the slab. It is cutting the right slab with the right Diameter.
However, when there is pipes whose distance to another is less than 6 centimeters i want to group then, and place a single retangular family to comprise all of the pipes in the area.


Yes this is possible.

  1. Add all families to a single list.
  2. Take any one circle, and remove it from the list and place it in a new list.
  3. Offset the circle by your 6cm offset.
  4. Do a bounding box intersection test with the rest of the list.
  5. For any true results add the circles to the new list, and remove them from single list. Repeat the offset and bounding box intersection test in steps 3 and 4.
  6. Repeat step 5 until no more circles are intersecting. The resulting list is your rectangular opening.
  7. Return to step 2 (which should be n+adjacent n less than when you started), and repeat steps 2-6 until no more circles are in the list.
  8. The if the list length for each n grouping is greater than 1 it needs a rectangular opening placed at the center point and scaled up. You could try the center point of a line by best fit through center points, or the centroid of the convex hull to find the insertion point.
  9. You can then do a bounding box or other method to find the length/width of your opening family.

Good luck


Try the Geometry.GroupByDistance node from spring nodes.


I used that node and it nearly solved my problem. it grouped the points that are distant by 6 cm, however, in a rather awkward manner.
Have a look

We can clearly see that the circle [0,0,0] is too far from [0,0,3…6]
It would create a really long shaft and that is not what i’m looking for.
any Suggestion?

Did you try adjusting the margin?


I thought about doing that but it didn’t work… and it won’t work for a lot of pipes…
However i thought about doing something with statistics calculus… Something like creating an average point and measuring the distance of all circle center points to this average point. Than calculate the average of that distance, and group the ones with the highest standard deviation in another group…

@ramoon.bandeira Would this serve your purpose?

  1. Pair closest circles
  2. Filter out circles that are beyond the specified distance (0.5, in the example below)
  3. Create rectangular boundary around circle pair

groupCircles.dyn (42.8 KB)