Dealing with TaskDialogs

I found this great AU talk on handling Task Dialogs and thought I would share it here

But these are the codes for task dialog interactions -


Here is how I made a smartpushbutton for a taskdialog handler I created for temporarily disabling the service mismatch warning for fabrication parts.

I added the dll and addin file into my ribbon github, and the addin file is automatically copied to the appropriate folder if it is missing to automate distribution during Revit startup to about 200 different users.

We have a separate fabrication service for cans and sleeves for wall and deck pens that hosts to the pipe, and it was really annoying getting a service mismatch on every single sleeve placed.

Used an existing smartpushbutton as a template

import re
import os
import shutil
import os.path as op
from pyrevit import script
from pyrevit.coreutils.ribbon import ICON_MEDIUM
from pyrevit import HOST_APP, UI

uiapp = HOST_APP.uiapp

logger = script.get_logger()

folder_paths = [

# File name to check in each folder
target_file_name = 'DisableServiceMismatch.addin'

# Source file to copy
source_file = 'ribbon\\path\\to\\dll\\DisableServiceMismatch.addin'

for folder in folder_paths:
    if os.path.isdir(folder):
        target_file_path = os.path.join(folder, target_file_name)
        if not os.path.isfile(target_file_path):
            shutil.copy(source_file, target_file_path)


def __selfinit__(script_cmp, ui_button_cmp, __rvt__):
    on_icon = script_cmp.get_bundle_file('on.png')
    off_icon = script_cmp.get_bundle_file('off.png')

def toggle_state():
    new_state = not script.get_envvar(DISABLEDIALOG_ENV_VAR)
    script.set_envvar(DISABLEDIALOG_ENV_VAR, new_state)

if __name__ == '__main__':


Brilliant! thanks for sharing mate!