UI Extensions can contain a
hooks/ subdirectory. This directory can contain especially named scripts that would hook up to the Revit event system and will get executed whenever that event occurs. For example, a
doc-changed.py hook script, gets executed automatically every time DocumentChanged event occurs in Revit.
hooks/directory. There are many events firing when working with Revit and having too many hooks will reduce performance dramatically due to the overhead of reading, compiling, and executing an external code file every time an event occurs.
↓ Read the guide below for information on how to write hook scripts
Anatomy of Hook Scripts
Hook Script Types