Compare two huge lists

Hi,
I have two lists. List A contains around 2000 rooms with around 10 boundary curves → total 20000 curves. List B contains all walls curves around 9000 curves. I want to compare every curve on list A to all of the wall curves on list B.
This process takes me forever.
My goal is to take the nearest wall, and match it with the closest room boundary curve.
room.boundaries doesnt work, coz all the walls are from linked model, but my rooms are on current model.

Which version are you using? No problem in getting Geometries with my Dynamo 2.6.1.
The only problem is that your model is so big.

1 Like

You can get the the elements defining the room using a python script node like this;

import clr
import sys
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument
rooms = UnwrapElement(IN[0])
result = []

for room in rooms:
    roomBoundingElements = []
    nestedRoomBoundaries = room.GetBoundarySegments(SpatialElementBoundaryOptions())
    for nestedBoundary in nestedRoomBoundaries:
        for boundarySegment in nestedBoundary:
            roomBoundingElements.append(doc.GetElement(boundarySegment.ElementId))
    result.append(roomBoundingElements)

OUT = result

I don’t know if this is what you need, because I could not understand when you mentioned “the walls are from linked model”. However, I tried this on 4000 rooms and it listed all these in a couple of seconds

1 Like


yes my project is big
even I do it manually level by level it takes so long time.
I used your python script for matching the closest distance between curves

your script last time:
but still takes long time like 1 hour

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line
geos1=IN[0]
geos2=IN[1]
min=IN[2]
bools=[]#determin set
dists=[]#distance between set
for geo1 in geos1:
	temp=[]
	dtemp=[]
	for geo2 in geos2:
		bool = False
		dist=geo1.DistanceTo(geo2)
		if dist<min:
			bool=True
		dtemp.append(dist)
		temp.append(bool)
	bools.append(temp)
	dists.append(dtemp)
	
# Assign your output to the OUT variable.
OUT = bools,dists

Maybe some workaround can be found if the final result you want is known.