I'm trying to trigger a function when the user activates a view. I've successfully done this by using the ViewActiaved event. However, if the user has a sheet as the active view and they acitvate a view on the sheet the ViewActivated event is not trigger. I know the ProgessChanged event is fired during this activating of the view, but I don't want to slow the system down by checking all of those events.
If there another option?
Dear atiefenbach,
Thank you for your query.
Did Remy's suggestion help?
Here is another one from Joe Ye:
I am thinking if we can use the Idling event. For example, when the active view is non-sheet view, and the document’s previous active view is the non-sheet view’s host sheet (judge by the Sheet Number property value). In this case it may be activated from the sheet view if the view change cannot be captured the ViewActivated event.
As an extension of both Remy's and Joe's suggestions, you might be able to reduce the overload and system performance degradation caused by the Idling or some other all-too-frequent event notification by defining your own external event yourself and trigger that in a timer at less frequent intervals.
I demonstrated that approach in the discussion on replacing an Idling event handler by an external event for my real-time round-trip cloud-based simplified 2D BIM editing RoomEditorApp subscription to real-time database changes:
http://thebuildingcoder.typepad.com/blog/2013/12/replacing-an-idling-event-handler-by-an-external-ev...
I hope that helps.
Best regards,
Thanks for all your great responses! I'm definitely going to bookmark Jeremy's blog post because I'm sure there will be a day I want something similar. Although I think all of those are viable solutions I don't think I want to spend too much time trying to make it work, right now, because it's not a neccessary function to office productivity. I'm afraid my small amount of API knowledge might cause too much grief if I code some sort of idling event incorrectly.
I was looking for a simple solution, like the ViewActivated event, to work in this instance. Is it possible, to add this to the API wishlist, though, so that future realeases will have the ViewActivated event fire in these instances. I mean, I am activating a view afterall.
Thanks!
Hello Atiefenbach,
in fact, you are not activating a view 🙂 What you do is activating a viewport on a sheet. That is different from activating a view in a Revit document, which basically means that a different view in a MDI environment gets a focus. Also, please note that activating a sheet's viewport has no effect on ActiveView property of that document.
That being said, I agree that a request for adding new viewport related events should be added on the wish-list for future releases.
In the meantime, I think using the ProgressChanged event would be the best approach, assuming raising the event in this situation is dependable and you can make it work for you.
Arnošt Löbel
Autodesk, Revit R&D
Unfortunately you are wrong. The ActiveView will be the one in the viewport instead of the sheet.