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
This is how I’m hoping to use this updater by the way, nothing too complicated, right? It doesn’t find the exact width and length of rooms that are off-axis or funny shapes, but for a majority of rooms it should work.
from pyrevit import EXEC_PARAMS
from pyrevit import revit, DB
def round_to_nearest_inch(n):
return round(n * 12) / 12
doc = EXEC_PARAMS.event_args.GetDocument()
for room in revit.query.get_elements_by_class(DB.Room, doc=doc):
w = room.LookupParameter("Width")
l = room.LookupParameter("Length")
rBoundingBox = room.get_BoundingBox( None )
width = rBoundingBox.Max.X - rBoundingBox.Min.X
length = rBoundingBox.Max.Y - rBoundingBox.Min.Y
w.Set(round_to_nearest_inch(width))
l.Set(round_to_nearest_inch(length))
Any progress?
I’m also into the IUpdater implementation and it seems that “doc-updater” is detected but I also got the error that NoneType object has no attribute 'VersionNumber". So it is not detecting the application?