Suppressing doc-changed pop-up windows

Is there a way to suppress all these doc-changed event popup?

I used to have print statement in one window, however when I introduced a doc-changed script the print statement jumped to the doc-changed instead.

Code needed…
Have you restarted pyRevit, because events are registered at startup in most cases

I tried restarting but to no luck

Here’s piece of code under the purgeUtils lib

import logging
import os
import sys
from pyrevit import HOST_APP, EXEC_PARAMS

LOG_PATH = os.path.join(os.getenv("USERPROFILE"),
                'revit_log.txt')
LOG_FORMAT = "%(asctime)s %(levelname)s [%(name)s] %(message)s"

logging.setLoggerClass(logging.Logger)

filehandler = logging.FileHandler(LOG_PATH)
filehandler.setLevel(logging.DEBUG)
filehandler.setFormatter(logging.Formatter(LOG_FORMAT))
logging.root.addHandler(filehandler)

streamhandler = logging.StreamHandler(stream=sys.stdout)
streamhandler.setLevel(logging.INFO)
streamhandler.setFormatter(logging.Formatter("%(message)s"))
logging.root.addHandler(streamhandler)

logging.root.setLevel(logging.DEBUG)
logger = logging.getLogger(EXEC_PARAMS.command_name)


def purgeRevitLinks(doc):
    """
    Purge all Revit links from the document.

    :param doc: The Revit document to purge Revit links from.
    """

    rvt_links = DB.FilteredElementCollector(doc).OfClass(DB.RevitLinkInstance).ToElementIds()
    revit_link_types = DB.FilteredElementCollector(doc).OfClass(DB.RevitLinkType).ToElementIds()

    with revit.Transaction('Purge Revit Links', doc,swallow_errors=True) as t:
        for rvt in rvt_links:
            try:
                doc.Delete(rvt)
                # print("Deleted Revit link")
            except:
                pass

        for rvt_type in revit_link_types:
            try:
                doc.Delete(rvt_type)

            except:
                pass
    logger.info("number of Revit links deleted: {} \n number of Revit link types deleted: {}".format(len(rvt_links), len(revit_link_types)))

here’s how Implement it in the script.py

# -*- coding: utf-8 -*-
from pyrevit import forms
from pyrevit import revit, DB, HOST_APP,script


import os
import uiUtils
import json
import purgeUtils


revit_doc = HOST_APP.doc
uiapp_version = int(HOST_APP.uiapp.Application.VersionNumber)
def loadViewNames():
    init_dir = os.path.join(os.getenv("USERPROFILE"), "GSA", "View_Export")
    if not os.path.exists(init_dir):
        os.makedirs(init_dir)

    selected_view_file = forms.pick_file(file_ext="json",init_dir=init_dir, title="Select the file with the view names",multi_file=False)
    if not selected_view_file:
        uiUtils.showErrorMessage("No file selected")


    selected_views_names = []
    if selected_view_file:
        with open(selected_view_file, 'r') as f:
            selected_views_names = json.load(f)
    return selected_views_names


if __name__ == "__main__":
    if revit_doc.IsWorkshared:
        forms.alert("This script does not support workshared files", exitscript=True)


    # Purge Revit links
    purgeUtils.purgeRevitLinks(revit_doc)


    output = script.get_output()
    output.close_others()

the file doc-changed.py is all empty .

This is funny. I struggled a while ago with this and posted a food for thoughts yesterday. I think it’s due the fact that the hooks trigger a new windows.Id for the pyrevit script output. Perhaps discuss it further there?