SelectFromList / Select Sheet - preselected items

Hi Forums,

It been a while but i have a question to ask :slight_smile: !
For the select forms and other selection forms in the pyrevit lib, is it possible to have a preselection configured?

i found the example below on the dev pages but this is using a predifend list and the TemplateListItem Class.

How should i approach this if i have for example a list of sheets and based on a parameter value i want the sheets to be already checked or not. could the above be done with the forms.select_sheets() function?

Hi @AlexanderVDB !

Im afraid it can be done, since select_sheets doesn’t provide a way to pass selected sheets (only a filterfunc that shows only the items that match the result of a function).

You have to copy the code and rewrite the parts you need.
If could be a simple set of sheet names to check for during the creation of the SheetOptions items, or change it completely to accept a list of sheets/sheet options created externally.

@sanzoghenzo thx for the insight.
i have worked out a way to make it possible via the TemplateListItem class:

for sheet in sheets_sorted:
    #check if draft is already aplied
    sheetlist.append(draftsheets(sheet, checked= draftcheck(sheet,[legends['000.00_Draft_groot'],legends['000.00_Draft_klein']])))

and i do get the selection window as disered :slight_smile: .

2 Likes