Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

catch view scale change

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Ning_Zhou
738 Views, 2 Replies

catch view scale change

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?

2 REPLIES 2
Message 2 of 3
Scott_Wilson
in reply to: Ning_Zhou

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;
    }
}

 

 

 

Message 3 of 3
Ning_Zhou
in reply to: Scott_Wilson

right, i used wrong filter, thanks sdwil2k5.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community