Grouping text notes by location

Hi,
We’ve recieved a rather poor DWG-file and extracted text from that DWG in Revit. What we aim to do is to create a room list in Excel based on the information that we’ve got and my idea is to group single line text elements together by location with an tolerance so that both Room number, name and area can be coupled together for extraction to excel. But extracting point locations for the text elements and comparing them to all the other text elements positions is very computationally heavy and I wondered if anyone got a alternative suggestion in this matter? (ie a node like the Tool.GetSurroundingElements would be an option, but doesn’t work in this example.)

1 Like

Here’s one quick and dirty option:

Excellent Dimitar, however it turns out that it’s a little too dirty when one of the three text elements position suddenly drops below the precision. I’ll post my findings if I can get closer. Thanks anyway!

Maybe you can tweak this python example to work with your points:

Yeah that could be one possibility, however K is not fixed since there is some places that the room data is not consistent. Some places there are just 1 line of text containing just the room number for instance.

That looks like overkill and besides numpi is not available for iron python. Archi-lab’s “Group Curves” node logic can be adopted to solve this problem in a much neater way.

Would the “group curves” approach give any different result than the “Round point” apporoach? Maybe if you calculated an average point to the group to compare with for each iteration.

I made a workflow some time ago that creates rooms based on imported DWG text. What it does is create vertical lines downward and check to see if those clash with horizontal lines that are created at all other text locations. You could try a similar approach for your problem I think.
I even made a video of the workflow :slight_smile: https://youtu.be/IjbnDhITkWE

Room creation by dwg txt import.dyn (54.4 KB)

3 Likes

I have modified Konrads Group Curves to work with points. Maybe if it was modified to find the distance to the nearest point in an group, a lower ignore distance would have worked.

#Copyright(c) 2015, Konrad Sobon
# @arch_laboratory, http://archi-lab.net
#join/group curves
# Changed to work with points by Einar Raknes, 2016 

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


def groupPoints(point_list,ignore_distance): 
	grouped_points = [] #A list  that contains point groups
	queue = set() #A queue set (contains only unique items)
	while point_list: 
		point_group = [] #A list that contains points that are within the ignore_distance
		queue.add(point_list.pop()) # Move the last point from the point_list to our queue 
		while queue:
			current_point = queue.pop() #Get the last item in the queue and remove it from the queue.
			point_group.append(current_point) #Add the current point to the point_group
			for potential_match in point_list: 
				distance = current_point.DistanceTo(potential_match) 
				if distance <= ignore_distance:
					queue.add(potential_match) 
			point_list = [item for item in point_list if item not in queue] #removes points in queue from point_list

		grouped_points.append(point_group)

	return grouped_points 

OUT = groupPoints(IN[0],IN[1])
7 Likes

Nice @Einar_Raknes ! And to you as well, @T_Pover I’ll check your solution out! Here’s is as far as I got for now.