Collect all entries for a BuiltInParameter

Hi there!

I am trying to wrap my head around how to collect all the Departments in a project. I’ve read through many examples (,, ), but they all rely on some filter to cull results, or at the last link they get just one Department from one room element. I know the builtinparameter enumeration is ROOM_DEPARTMENT, I would like to collect all of them. I’m sure it’s simple and I just haven’t seen it done yet… right? :weary:

Something like this?

from pyrevit import DB, revit

doc = revit.doc


RoomDepartmentCollector= DB.FilteredElementCollector( doc ).OfCategory(DB.BuiltInCategory.OST_Rooms).ToElements()

RoomDepartmentCollector_count= str(len(RoomDepartmentCollector))

rooms_names_and_departments =[]

for i in RoomDepartmentCollector:
    rooms_data = []

print (rooms_names_and_departments)

loads of documentation around that topic:

I would do something like this to collect all values of room departments (untested).

all_rooms = DB.FilteredElementCollector(doc)\

all_departmenets = set()

for room in all_rooms:

Ahh so there is no direct way to collect the Departments, I would have to loop through all the rooms to get them, and using a set() makes it so duplicates are eliminated. Nice solution, too bad there isn’t a more efficient way (ie skipping the room collection step).

Also, if a Department was created earlier, but then deleted from all rooms, this method misses collecting that Department value. Maybe there is another way???

Thanks for the help so far - any other ideas?

You are correct that this would only gather in-use departments. For the deleted departments, can you access that information from anywhere inside the standard user interface?
As far as I can tell it’s just a text parameter, so if the information goes away it’s not in ‘some master list’ elsewhere.
(An example of this master list is the Space Type parameter)

They’re available in a “master list” of sorts in the Edit Color Scheme dialogue.

I believe they just added support for color schemes to the API in revit 2022. DB.ColorFillScheme.GetEntries() --> ColorFillSchemeEntry.GetStringValue()
I haven’t really played around with this yet, though.