Shift-Click Config


Just wondering if someone could provide a basic example how to write script so that you can do Shift-Click to bring up a config window for the main script? For example, the config menu could have 2 tick boxes “item 1” and “item 2”. If you tick “item 1” in config menu, the main script will print out “item 1” when it runs, same with “item 2”. I tried to follow the Pick tool from pyRevit but the coding of that tool is quite advanced and I don’t really understand it. Thank you.

Hi Jason,
here, very basic example explanation

live one in the pyrevit extension itself:


the config file looks like this
“”“Minify UI tool config”""
#pylint: disable=E0401,C0103
from pyrevit import script

import minifyui

config = script.get_config()

  1. calls the script by default
  2. shift+click calls #2
1 Like

so after looking at the example, I’ve written a simple example script to just basically print “item 1” or “item 2” based on the selection in config menu. Here’s the script:

from pyrevit import forms
from pyrevit import script

my_config = script.get_config()

class FSCategoryItem(forms.TemplateListItem):
    """Wrapper class for frequently selected category list item"""

def load_configs():
    selection_config = my_config.get_option('selection_config',[])
    return selection_config

def save_configs(selection_item):
    my_config.selection_config = [x for x in selection_item]

def config_menu():
    prev_config = load_configs()
    item_list = ["item 1", "item 2"]
    selection_config =[FSCategoryItem(x, checked = x in prev_config) for x in item_list], title = 'select',button_name = "Select Item", multiselect = True)

    if selection_config:
    return selection_config

if __name__ == "__main__":

and here’s the main script

import config

source_selection = config.load_configs()

if source_selection:
    for item in source_selection:

From the example from pyRevit tools, it seems like the config menu relies on the forms.SelectFromList in combination with [FSCategoryItem(x, checked = x in prev_config) for x in item_list] with FSCategoryItem is a class inherited from pyrevit TemplateListItem. Just wondering if it is a must to use SelectFromtList for config or this could be extended to other user interface like FlexForm from rpw too?