FilteredElementCollector:Filter the models displayed in the active view in the RevitLinkInstance

FilteredElementCollector:Filter the models displayed in the active view in the RevitLinkInstance

SimonaQQ
Advocate Advocate
1,844 Views
3 Replies
Message 1 of 4

FilteredElementCollector:Filter the models displayed in the active view in the RevitLinkInstance

SimonaQQ
Advocate
Advocate

Hi All,

I'm trying to filter models in the active view

 

 

var wallList = new FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(typeof(Wall)).ToList();

 

 

It works well in the local document.However, when the model is in revitlinkinstance, it does not work

 

 

new FilteredElementCollector(linkDoc, doc.ActiveView.Id).OfClass(typeof(Wall)).ToList();

 

 

This throws an exception.

So, how do I filter the models in the active view in revitlinkinstance?

Thank you!

 

0 Likes
Accepted solutions (1)
1,845 Views
3 Replies
Replies (3)
Message 2 of 4

caroline.gitonga
Autodesk
Autodesk

Hi @SimonaQQ ,

The first step to accessing linked data in Revit API is to get all the active documents loaded in the current Revit session. This will use Application.Documents().The returned collection will include both local and linked documents. We can then filter the collection to obtain the Linked documents only. By iterating through the Revit Linked documents collection , comparing the name of the Linked File with that of the document object you can get the actual document you wish to work with. Once you get the right document, you can be able to get the elements using your line of code you have provided.

Kindly refer to these resources for more detailed explanation.

Thanks

Carol Gitonga, Developer Advocacy and Support, ADN Open
0 Likes
Message 3 of 4

SimonaQQ
Advocate
Advocate
Hi,
First of all, thank you very much.
Maybe you didn't understand me because of my poor English.
What I want is to filter the model displayed in the current active view, and the model is in revitlinkinstance.
So I use the new filteredelementcollector (DOC, Doc. Activeview. ID), an overloaded method with view ID.
0 Likes
Message 4 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @SimonaQQ ,

 

Please take a look at this below link

https://forums.autodesk.com/t5/revit-api-forum/collect-elements-from-link-document-in-view-of-host-d... 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network