Script output taken over by hooks.doc-changed.py

Happy almost new year everyone, I got a but I’ve had trouble trying to suppress so hopefully someone here may know the solution:

I’ve been creating a script very similar to the “Copy Sheets to Open Document”, utilizing the base code and changing it to fit my specific needs. It works just fine with all the changes made (TL;DR: the source document is pre-determined/hardcoded & script is now run in the destination document).

The one issue I’m facing right now is that when I run the script and I make the selections for which sheets to copy, the output window will proceeded to output the first two messages, then a new output window will open, with the title “hooks.doc-changed.py”. This then happens several other times depending on how many sheets I’m copying over.

For troubleshooting, I did comment out my entire doc-changed.py script which did nothing to resolve the issue. Trying pyrevit’s “copy sheets to open documents” did not produce the same issue. Would anyone have a guess as to why a new output window would keep opening under the hook/has someone experienced this before? If needed I can share the source code (once I go though and redact some stuff).

Thanks!

Hi,
The hook registers itself at application startup. It stays in memory until you close this session of the app.
So if you made changes to the hooks’code you need to restart Revit to live the results of the changes ( or restart the pyrevit engine but it does not always behave as expected - restarting is safer in my experience)

Thanks for the tip, unfortunately the issue still persists after commenting out the contents of my doc-changed hook and restarting revit, so troubleshooting continues :slight_smile:

One other note if someone may have an idea as to why this is happening/what the root to the issue is, unlike “Copy Sheets to Open Document” which copies sheets across two open UIDocuments, this script opens a headless document. I’m thinking this headless document may be the reason the doc-changed hook is opening new output window(s). Will update with any other developments

Update: Edited my script to copy sheets from another open UIDocument & the issue persists.
Update 2: Now I copied Copy Sheets to Open Documents to my extension & ran it and the same issue persisted. I suppose at this point the fix would be to put all my hooks in a separate extension which is sub-optimal, but should fix it

Did you ever figure out how to resolve your issues?

This sounds related to the problem I described here

I’m not opening background documents or anything. I’m attempting to modify elements that trigger my doc-updater script using a pushbutton script. I would expect the updater to fully execute within the transaction of my running script to update the parameters and not continue after the transaction has closed, yet it appears to hijack my output window that is not created or shown until after the transaction is closed.

edit: just realized you are talking about doc-changed.py, but I’m using doc-updater.py. still sounds like similar issue though