Isolate rooms and get wall dimensions

Hello !
I’m currently developping a program in which my main objective is to extract the length and height of the walls of a room. (And thus for each one, mainly for the walls that go on the outside)
I’m aware that by using FilteredElementCollector, I could get the Built in “Height” Parameter, but I’d want to do that for a specific room. Is there any possibility to Isolate a room and then apply a code to it ?


For example, if I want to Isolate the D1.3a room ?

Thank you in advance

Hi @Matteop,

What do you have so far as code?

I don’t have much code, I’m still searching for ideas of what to use from the API, yet I think something like this should work at a certain extent :
every_wall = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()

for wall in every_wall:
wall_type = wall.WallType.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString()
wall_height = wall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble()

I think the best thing you can do is to use room bounding property. Or cut walls :smiley:

Do you mean cut walls manually ?

@Matteo,
to get you fursther and collect walls id per room

from pyrevit import revit, DB, script

output = script.get_output()
output.close_others()
output = script.get_output()

doc = revit.doc

def walls_by_rooms(doc):
    rooms = DB.FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(DB.BuiltInCategory.OST_Rooms).ToElements()
    map_wall_to_rooms = {}
    opts = DB.SpatialElementBoundaryOptions()
    for room in rooms:
        loops = room.GetBoundarySegments(opts)
        room_id = str(room.Id.IntegerValue)
        room_name = [room.get_Parameter(DB.BuiltInParameter.ROOM_NAME).AsString()]
        map_wall_to_rooms[room_id] = []
        # or
        # map_wall_to_rooms[room_name] = []
        for loop in loops:
            for segment in loop:
                idWall = segment.ElementId.IntegerValue
                if(DB.ElementId.InvalidElementId != idWall):
                    if idWall not in map_wall_to_rooms.values():
                        map_wall_to_rooms[room_id] += [idWall]
                        # or
                        # map_wall_to_rooms[room_name] += [idWall]
    return map_wall_to_rooms

print(walls_by_rooms(doc))

inspired by https://github.com/jeremytammik/the_building_coder_samples/blob/13eb0e37e20dabfc3f99bd0115f41a07f811f463/BuildingCoder/BuildingCoder/CmdRoomWallAdjacency.cs

This seems pretty effective indeed, thanks a lot, I’ll try to work with that !