Creating a CheckBoxList

Hi everyone,

I’m trying to create a GUI using the rpw.forms.
Is there a function to create a list of checkboxes (CheckBoxList), or is there a tutorial somewhere that teaches me to create that function.
The result should look like this, but I want the elements to be variable (list or dictionary):

Any help is appreciated!

Welcome @PieterL_TM
That’s what you are after
It is all builtin pyRevit module so no extra effort on your side, that’s the beauty of it.

or in a more dev docs way

bare minimum example:

from pyrevit import forms
items = ['item1', 'item2', 'item3']
forms.SelectFromList.show(items, button_name='Select Item', multiselect = True) # the multiselect argument set to True will toggle checkboxes

1 Like

Yess, this seems to be what I’m looking for!
However, can I use this function within a Flexform?

No idea, I haven’t tried the combination, if you can find something similar in the pyRevit tools, I guess yes,
or you can look in some of the code of the pyChilizer tools extension for example, they use flexforms extensively.

probably also in what @ErikFrits is using in its set of tools EF-Tools GitHub - ErikFrits/EF-Tools: Save your time and nerves with EF-Tools. It's a pyRevit Extension for Autodesk Revit. There are 40+ tools in the toolbar and you will be able to improve your workflows or even discover new ones.

I started making my own custom GUI with WPF, but before I used pyrevit.forms.SelectFromList with dictionaries.

I prepare a dict to contain human readable names as keys, and elements as values.

Then I provide a list of keys to SelectFromList and once user selects something you can get element from your dictionary by using the selected name(key).

Example:

all_floor_types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsElementType().ToElements()
dict_floor_types = {Element.Name.GetValue(fr):fr for fr in all_floor_types}



selection = forms.SelectFromList.show(dict_floor_types.keys(),title="Select Floor Type", button_name='Select')
if not selection:     
    forms.alert("Floor Type was not chosen. Please try again.", title='Select Floor Type', exitscript=True)
selected_floor_type =  dict_floor_types[selection]

If you want more customization for your GUI, you will have to learn WPF, but it’s not very easy, considering all resources are C# oriented. I learnt it by watching C# tutorials and then manually trying to translate it to python. I spent hours debugging simple things when I started, so be aware of that.

Thanks for mentioning @Jean-Marc!

1 Like

hi there!
This is my first question and I’m excited to work with pyrevit!!
how about using combobox with checkboxes?