@cridder asked me this question in an email. Here is an example of
view-activated.py hook script that ensures any view you open in Revit is zoomed to fit.
from pyrevit import revit from pyrevit import EXEC_PARAMS cview = EXEC_PARAMS.event_args.CurrentActiveView for view in revit.uidoc.GetOpenUIViews(): if view.ViewId == cview.Id: view.ZoomToFit()
For context, the
ZoomToFit() method is a method of
UIView class (ApiDocs.co) so we have to find the UIView instance pointing to the view first