IUpdater with Views Question

IUpdater with Views Question

george.potts
Enthusiast Enthusiast
479 Views
4 Replies
Message 1 of 5

IUpdater with Views Question

george.potts
Enthusiast
Enthusiast

Hi All. I am attempting to implement an updater that works off of Views in a document. I'd like to use this to help sync a 2D view with a 3D view, within the currently active document. I have some code that does this via a button click, but I can't figure out the triggering part while rewriting to use Iupdater (to avoid the use of transactions clogging up the undo list).
I am using a win form to deal with the user input aspect:

georgepotts_0-1680261854821.png

 

 

 

private void liveSync_Click(object sender, EventArgs e)
        {
            DialogResult result = liveSync.DialogResult;
            if (result == DialogResult.Yes)
                //Button clicked twice, avoids it making more than one.
                return;
            else
                try
                {
                    //run and create updater
                    liveSync.DialogResult = DialogResult.Yes;

                    // Register view updater with Revit
                    UpdaterRegistry.RegisterUpdater(updater, doc);
                    ElementClassFilter viewFilter = new ElementClassFilter(typeof(Autodesk.Revit.DB.View));

                    // Add trigger, if view via filter.
                    UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), viewFilter, Element.GetChangeTypeAny());

                    Autodesk.Revit.UI.TaskDialog.Show("SDS Custom Tools - Common", "Updater is live: " + updater.GetUpdaterId());
                }
                catch (Exception ex)
                {
                    Autodesk.Revit.UI.TaskDialog.Show("SDS Custom Tools - Common", "Updater Error: " + ex.Message);
                }
        }

 

 

 

This is what I have got so far for dealing with "switching it on". This returns an error:

 

 

 

[Window Title]
Sync 3D View to Active Plan View - SDS Custom Tools - Common
[Main Instruction]
Updater Error: The input argument "updater" of function Autodesk::Revit::Proxy::DB::UpdaterRegistryProxy::RegisterUpdater or one item in the collection is null at line 101 of file d:\ship\2020_px64\source\revit\revitdbapi\gensrc\apiupdaterregistryproxy.cpp.
Parameter name: updater

[Close]

 

 

 

 

So I thought, I will need to iterate each view and use the Collection version of the AddTrigger method, thus adding the trigger to every view, firing the updater to do the appropriate checking of views types etc.


Does anyone have some feedback on fixing this? I do fear I may not understand the addTrigger properly as well, if someone could explain this a little better that would be awesome!

George

Accepted solutions (1)
480 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni
Accepted solution

Did you look at the explanations and samples provided by The Building Coder?

  

  

They include several simple calls to the AddTrigger method:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 5

george.potts
Enthusiast
Enthusiast

Hi Jeremy, yes as you've likely heard many times before its been very helpful. I am just struggling to understand it a little. I will give the example at

https://thebuildingcoder.typepad.com/blog/2012/06/documentchanged-versus-dynamic-model-updater.html

a go and then see if I can solve my problem.

0 Likes
Message 4 of 5

jeremy_tammik
Alumni
Alumni

Thank you for the appreciation, best of luck to you, and I wish you a happy and successful weekend 🙂

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 5

mhannonQ65N2
Collaborator
Collaborator

Based on the error message you shared, it looks like your updater field is null.

0 Likes