i don't know if there's a good way to catch view scale change besides ViewActivated and/or ViewActivating event, IUpdater won't catch it either (?), anyone?
Solved! Go to Solution.
Solved by Ning_Zhou. Go to Solution.
Create a temporary dictionary in memory when a document is opened (as a static member of your main IExternalApplication class maybe?) containing each view's elementId and corresponding scale, then use an IUpdater event handler to detect any changes to the View element and test the view's current scale against the entry in the dictionary. You should also use the updater to detect added views so that thier details can be added to the dictionary.
I just did a quick test and can confirm that in Revit 2014 changes to a view's scale will trigger an IUpdater event that will provide the elementId of the View element from which you can read the scale value.
Here's the IUpdater.Register method I used for my test, it should get you in business. Note that it also checks for added and deleted views so you can keep your dictionary up to date. You can probably get rid of the _IsRegistered check if you want, it's just a private class member that I use to check whether the updater is registered before both registering and unregistering.
public static void Register(AddInId addInId) { if(!_IsRegistered) { Updater updater = new Updater(addInId); UpdaterRegistry.RegisterUpdater(updater); ElementClassFilter viewFilter = new ElementClassFilter(typeof(Autodesk.Revit.DB.View)); ChangeType changeType = ChangeType.ConcatenateChangeTypes(Element.GetChangeTypeAny(), Element.GetChangeTypeElementDeletion()); changeType = ChangeType.ConcatenateChangeTypes(changeType, Element.GetChangeTypeElementAddition()); UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), viewFilter, changeType); _IsRegistered = true; } }