IUpdater Interface / Dynamic Model Updater

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))