Group by distance

there is a springnode groupbydistance…

this nodes works pretty good and groups geometry that is close to each other…
i am using it to group walls that are close to each other.

Now i was hoping that it would group it in a fashionable order so if i took the first and the last item that i then have the outer walls… unfortunately this is not the case…

Does some one know how to adjust this python script… so that or the output is in a chronological order… or the output is only the outer geometry of the geometry close to each other.

#Copyright(c) 2016, Dimitar Venkov
# @5devene, dimitar.ven@gmail.com
#Inspired from the "Group Curves" node by Konrad Sobon
# @arch_laboratory, http://archi-lab.net

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import Geometry

pts = IN[0]
margin = IN[1]
dist1 = Geometry.DistanceTo

Groups, Queue = [], []
while pts:
	group = []
	Queue.append(pts.pop() )
	while Queue:
		p1 = Queue.pop()
		group.append(p1)
		for i in xrange(len(pts)-1,-1,-1):
			if dist1(p1, pts[i]) <= margin:
				Queue.append(pts.pop(i) )
	Groups.append(group)

OUT = Groups
1 Like

within the group it needs to look at the elements with the greatest distance