Hello everyone! I created a tool that determines the width and length of all rooms in a project and am looking into how I can convert it from something that needs to be manually updated from time to time via a pushbutton on the UI to something that runs automatically in the background like these examples:
Is it as simple as converting one of those examples into python and then putting it into an Extension Startup Script?
I can post my code for the pushbutton if necessary but I’m still in the conceptual stage for this auto-dynamic model updater. Thanks in advance for any assistance!
Thanks for your reply! Yes, I originally wrote my room update script as a doc-changed hook but I wasn’t sure how I could piggy-back on the previous transaction. I would like to avoid creating a new Revit Transaction. Is there a way to make it so certain transactions do not show up in the Undo/Redo history? I thought the IUpdater interface might be a good way to go because this Revit help page described pretty much what I would like to achieve:
Dynamic model update offers the ability for a Revit API application to modify the Revit model as a reaction to changes happening in the model when those changes are about to be committed at the end of a transaction.
That would be super amazing! I think there are lots of use cases for the IUpdater Interface that would justify getting it set up in pyRevit. The hardest part for me has been translating the C# examples to python and how scripts interact with each other. Having it as a hook would be very nice
Okay so this is where the implementation is going:
You can add hooks/doc-updater.py as a hook script that gets tied to and internal pyRevit IUpdater handler
On every element change, pyRevit will run your hook and will pass the UpdaterData as arguments
Example
This hook script sets the wall heights to 5 on model changes
from pyrevit import EXEC_PARAMS
from pyrevit import revit, DB
doc = EXEC_PARAMS.event_args.GetDocument()
for wall in revit.query.get_elements_by_class(DB.Wall, doc=doc):
p = wall.LookupParameter("Unconnected Height")
p.Set(5)
@eirannejad I’ve noticed that you are using ChangeTypeAny on all elements, and I’m afraid there is a high chance of infinite loop which will make Revit to disable the updater. Meanwhile I’m surprised that it still works as it is seen on the gif, and it doesn’t break. What is the trick?
btw the thing that you implemented the updater in pyRevit made me code my own ExternalApp that makes a Generic Annotation into a “Free” spot elevation, which can be placed enywhere on a section for instance, and still reports back its exact elevation in a label. So thanks for the inspiration
Hey @eirannejad sorry for my delay! I set up the pyrevit CLI and used it to clone the feature/updaterhook branch and then attached it to revit but it won’t open I followed @Jean-Marc’s post and some of your videos, I’m not sure what I’m doing wrong I can post the error message if that helps!
I don’t have any specific plans for the “ChangeTypeAny” potential issue. Unless we can come up with a system to specify some sort of element filtering for the doc-updater hook. I’m open to ideas