How to get the rooms/spaces that a wall element is generating their bounding?

maybe sounds like early bird question, but I do not remember how to do this, I wan to do it in python node of Dynamo with Revit API. How to get the rooms/spaces that a wall element is generating their bounding ? Thanks, not sure if that is resolved already in the forum, I searched before posting, I see like the way around in other posts how to get the walls around a room, but I have a wall and I want to know what rooms are surrounded and the wall forming their boundaries curves

A few options:

  1. Get the curve, get a point left of the midpoint of the curve, get the room at that point, remove the room’s curve from the base curve, and continue the process for the remaining curves. Then repeat for the other side.
  2. Build a dictionary using wall elements as the key and a list of rooms as the object. Then get all rooms, extract the boundary elements, and for each boundary element add the room to the list of dictionary’s key. When done you can use any selected wall as a key to pull the associated rooms.

Option 1 will likely be faster for single walls in a large plan. Option 2 will be faster for large collections of walls.

1 Like

what i do with curves? I do not see any benefit

Which option?

Use the GetBoundarySegments() method of the rooms / spaces to pull the Ids of the generating walls - then parse into dictionary for lookups on the wall id.

import clr

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

rooms = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements()

sebo = SpatialElementBoundaryOptions()
sebo.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish
sebo.StoreFreeBoundaryFaces = False

rooms_by_wall = {}

for room in rooms:
    for bseglist in room.GetBoundarySegments(sebo):
        for bseg in bseglist:
            if isinstance(doc.GetElement(bseg.ElementId), Wall):
                rooms_by_wall.setdefault(bseg.ElementId.ToString(), []).append(room)

OUT = rooms_by_wall
2 Likes

that will work only when rooms are created from wall finish layer instead of core or something else?

Will work for all bounding conditions; this just pulls the curve at the finish face - could also do it at center line just as well.

A faster option might be to use the defaultdictionary class which allows using the wall element as a key. This post has such an example: How to cut Solid with Terrain Surface - #8 by jacob.small

2 Likes

sounds like nightmare process, i reject to pass through thanks

Looks (or sounds) can be deceiving. I’ve built similar in the past and it’s blown other methods out of the water in terms of processing time - millisecond executions instead of dozens of minutes. Just means you ahve to step a little bit outside of your comfortzone.

sincerely, i just take a point or 2 probes and test isinsideroom and end of this history

If you’re just going to test two points and only for one wall, use a GetRoomAtPoint method rather than testing each room against each point (IsInside). You’re getting into a NxN number of tests instead of just using the known datapoints.

a point ins inside room/space or 2 from the element wall instance is how i solved it