Find nearest room for an element


In Solibri I can find nearest space/room for an object, and this I now want to do in Dynamo.

I have searched Google and found many things about objects inside a space or room. But I also want to get the objects just outside the rooms.

The rooms are in a linked file, and I’m electrical. I don’t want to use space.

Anyone that have a starting tip for me?

1 Like

Element.SurroundingElements from steamnodes I think.


It seams that this node functions like other solutions I have seen. That it creates a bounding box out of the room/space and checks if anything is inside. So it doesn’t do what I want it to do.

I want to get the room that sorrounds the element, and/or is nearest. This means that every elements should be mapped to a room. Even if it is 1 meter og 50 meters from a room, outside the building


Did you try “Element.Room” node?

1 Like

Hei Kulkul.
Yes I have tried that one and Element.Space.

They will do many of the things I want, but not 100%. Couse what I have an element inside the wall, over the ceiling, in the floor, on the outside wall and so on? I want theese elements to also get a room. They should get the nearest room/space.

And I guess element.Room doesn’t work with linked rooms.


For linked rooms there is a node from archi-lab package called “Elements in Room” that will give you elements inside rooms in linked.

1 Like

Thanks for that one:)
I have found several ways and nodes for getting elements inside a room.

The problem is getting nearest room/space. Perhaps the room only goes up to the suspended ceiling. I want the elements above the ceiling to belong to the room. Perhaps I have an element on a wall on the outside of the buiding. I want that element to belong to the nearest room/space.


Hi Rune, I don’t know will this help you, I get the elements nearest room number and write it to element comment or maybe custom shared parameter. But now it works only one element per room.

file:neares room to element.dyn (9.0 KB)


Thanks memortj.
I have come this close my self. But this function “surroinding.elements” works like all the other functions, i think. That it uses a bounding box and checks if anything is inside or collide. This one also has a tollerance. So i guess it could work.

Do you know what happens if the tollerance is so big that rooms gets overlapped? And perhaps there are a element that gets overlapped by two rooms. Wil it then get ro room numbers or is only the “closest” one selected?


@Rune_Haugland You are correct in your assumption, Tool.SurroundingElements uses the “BoundingBoxIntersectsFilter” witch filters out objects that are contained or intersects with the BB. The problem with bounding boxes is that they must be rotated along the global x and y axis. The image below shows two identical beams and columns, but the filter works differently on them because of the rotation:

Have you tried the Geometry.DistanceTo node? Here is an example:

1 Like
Bounding box issue
Running Revit Room Book from Dynamo

Elinar from which package is Collector.LinkedInstanceElements node ?






I ran it in a project and Revit/Dynamo got “not responding”.
I guess I should try it out on a small test project first.


@Rune_Haugland I don’t see a problem with any of the proposed answers above. The problem is that you are looking for a solution to 100% of all possible cases and that doesn’t exist. There is no limit to how poorly your users can model or how many different EDGE cases there can be so there is no way to come up with a silver bullet solution that will take care of them all without seeing them all. I am sorry to say that, but no matter how much we automate there will always be a human error factor involved and there will always be need for custom edge case solutions and maybe even some manual oversight. Unless you put in place a handful of very rigid modeling rules and have your human users follow through 100% of time, you won’t get an automation solution that works 100% of the time. Sorry to be a party pooper here.


Yes i know.
I have said that I have seen many solutions that finds objects inside a room. And i realise that what I want is mor complex, and probebly takes too long to compute in Dynamo. Today I use Solibri to get this information and send it back til Revit.

And I’m also aware that many scripts and Revit models have errors. All i can do is make the best of the situation.


Hi @Kulkul
Will it work for pipes and fittings?I’m trying it but got the below result.