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

Retrieve all elements on start-up.

2 REPLIES 2
Reply
Message 1 of 3
mohd.fadel
230 Views, 2 Replies

Retrieve all elements on start-up.

Hello everyone,

 

I'm trying to to implement an Updater in my code since documentChanged has some limitations regarding setting parameter values (in documentChanged they are read-only).

 

Everything is great! And i was able to register it using OnStartup(). However, i need to get all the elements in the document.

 

As i understand, the updater needs a trigger to get the change type (AddTrigger(UpdaterID, Document, IColllection(ElementId), ChangeType)) this overloaded function is what interests me. But how can i get the collection from the document while inside the OnStartup() function:

 

This is my function:

 

public Result OnStartup(UIControlledApplication application)
        {
           
            FilteredElementCollector collector = new FilteredElementCollector(doc);
            collector.WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilter(false), new ElementIsElementTypeFilter(true)));

            ICollection<ElementId> allLoads = collector.ToElementIds();


            if (null == _updater)
            {
                _updater = new WatcherUpdater(
                  application.ActiveAddInId);

                UpdaterRegistry.RegisterUpdater(_updater);


                UpdaterRegistry.AddTrigger(
                      _updater.GetUpdaterId(), doc, allLoads,
                      Element.GetChangeTypeAny());
            }
            else
            {
                UpdaterRegistry.UnregisterUpdater(
                  _updater.GetUpdaterId());

                _updater = null;
            }
            return Result.Succeeded;
}

 

As you can see, i scratched doc, this is what's i can't get implement. How can i get the document from UIControlledApplication?

 

I even tried to add the trigger (AddTrigger(UpdaterID, Document, IColllection(ElementId), ChangeType)) in my Execute function. I tried searching a lot but i can't find anything. I even tried implementing an Idling event in which i can get the collection. But still not working. 

 

Any thoughts are appreciated.

 

 

Thanks,

 

M. Fadel

2 REPLIES 2
Message 2 of 3
L.Maas
in reply to: mohd.fadel

No experience in the Revit API. Maybe your question is better suited for the Revit API Forum.

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

Message 3 of 3
mohd.fadel
in reply to: L.Maas

Ohh.. I'm really sorry!

 

I don't know how this happened.

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report