get all rooms revit api
public List<Room> getRoomFromLevel(Document document, Level level)
{
List<Element> Rooms = new FilteredElementCollector(document).OfClass(typeof(SpatialElement)).WhereElementIsNotElementType().Where(room => room.GetType() == typeof(Room)).ToList();
return new List<Room>(Rooms.Where(room => document.GetElement(room.LevelId) == level).Select(r => r as Room));
}