Rooms name in pyRevit form

Hi All,

I’m collecting rooms and I’d like their name displayed in a pyRevit form but the name_attr gives me an error. I’m not sure if there is another way. Do I need to get the rooms name manually ?


from pyrevit import forms
from Autodesk.Revit.DB import *

doc = __revit__.ActiveUIDocument.Document

rooms = FilteredElementCollector(doc)\

res =,
                                button_name='Select Room')

print (res)

You might have to use

room.LookupParameter("Room Name")

to access the Room Name parameter


How to compose this phrase within SelectFromList?
When I am trying it this way:,
                                name_attr=room.LookupParameter("Room Name")
                                button_name='Select Room')

I am having the error

                                name_attr=LookupParameter("Room Name")
                                button_name='Select Room')

is not working.

you will probably have to do it as a list comprehension
name_attr = [i.LookupParameter(“Room Name”) for i in rooms]

Unfortunately it won’t work

res =,
                                name_attr=[i.LookupParameter("Room Name") for i in rooms],
                                button_name='Select Room')

@shampoon Try Element.Name.GetValue(i) to get the name (i is the element instance in this example)


It won’t work this way. You’ll have to use a custom ListItem class that inherits from forms.TemplateListItem and override the name property there with the method @eirannejad suggested. I can show you an example once I’ll be in front of a pc.

I will be grateful if you can share mentioned example.

Okay, so you will need to implement a new class like

class RoomListItem(forms.TemplateListItem):
    def name(self):
        return Element.Name.GetValue(self.item)

for the list of rooms you need to have a list of these items made from the original rooms like

rooms = [RoomListItem(room) for room in rooms]

and when you create the UI with SelectFromList you won’t need the name_attr

1 Like

when having the example it looks very easy, but without it I was not able to solve my issue.
Many thanks, it is working now!:blush:

1 Like