Description
Getting all rooms in Revit means using the Revit FilteredElementCollector and filtering by the class. The only thing that needs to be rememberd is that a Room doesn’t directly inherit Element but instead you can use Spatial Element.
I wrote the C# version in a previous post: Getting al rooms with c#
In this article I will translate that in to Dynamo using python.
Solution
import clr clr.AddReference("RevitServices") from RevitServices.Persistence import DocumentManager doc = DocumentManager.Instance.CurrentDBDocument clr.AddReference("RevitAPI"); from Autodesk.Revit.DB import FilteredElementCollector from Autodesk.Revit.DB import SpatialElement from Autodesk.Revit.DB.Architecture import Room collector = FilteredElementCollector(doc) collection = collector.OfClass(SpatialElement).ToElements() rooms = [] for element in collection: if (element.GetType().Equals(Room)): rooms.append(element) OUT = rooms