No ViewActivated event fires when activating a Viewport

No ViewActivated event fires when activating a Viewport

schipmanU5A9G
Participant Participant
188 Views
1 Reply
Message 1 of 2

No ViewActivated event fires when activating a Viewport

schipmanU5A9G
Participant
Participant

The title is about all this post needs. It appears that activating a Viewport on a sheet does not fire the ViewActivated event. Testing this behavior is also as simple as it gets - I subscribe to the ViewActivated event, and it reliably fires when a view, a schedule, a legend, or a sheet is activated, but not when a viewport on a sheet is activated.

 

The result is that code which relies on the ViewActivated event to run some behavior must be run manually when a Viewport is activated, or contrive some other workaround. In my case, this is a modeless form which displays a truncated table of View Filters and overrides in the active view. When the user switches views, the form updates the list of filters and overrides automatically. But the automatic updating won't work when activating a viewport. So I have to expose a "refresh" button when a manual refresh is needed, (querying the UIDocument.ActiveGraphicalView in such a state does indeed return the active viewport's view as expected), or would have to run something on every Idling event, or run a background monitoring thread - out of these options, I like the manual refresh the best.

0 Likes
189 Views
1 Reply
Reply (1)
Message 2 of 2

rcrdzmmrmnn
Advocate
Advocate

Yea, I've seen similar posts about this problem. The way I'd go about it is to using the Idling event and the ViewActivated Event. When the ViewActivated event is fired, check if the view activated is a sheet, if it is, then, subscribe to the idling event to update the active view "manually". And when leaving the sheet(another ViewActivated event was fired and this time is not a sheet) unsubscribe to the idling event.
As you said, unfortunately, Revit does not catch viewport activation.

0 Likes