Collecting linked elements in view without knowing linked file instance?

Hi there,

the title says it all: is there a way to collect linked elements visible in a view without using the linked file?
In other words, what if we do not know which linked file to use, or do not care, and want to collect ALL linked elements of some category in some views?

thank you!

regards

gio

This is an extremely challenging thing to do. I have tried for the better part of a year but haven’t been able to figure out how to do so. See this relevant thread on the Revit API forum for more information.

Your situation, if I understand correctly, is this:

You have a federated model with multiple linked files–something like this:

Model-Federated.rvt
    Model-Link1.rvt
    Model-Link2.rvt
    Model-Link3.rvt

The federated model has a series of views (let’s just use a single view for this example):

Model-Federated-3DView1

Your goal is to get all elements, whether they exist in the federated model itself or any of the other links, of a given category.

Herein lies the problem. The Revit API provides the ability in a FilteredElementCollector to get all elements from a single document, of a given category, and in a given view. However, this requires that the view and elements all exist within the same document. The above view (Model-Federated-3DView1) does not exist in the linked documents, so doing this is valid:

# Pseudocode
doc = 'Model-Federated.rvt'
view = 'Model-Federated-3DView1'
elements = FilteredElementCollector(doc, view)

But this is not:

# Pseudocode
doc = 'Model-Federated.rvt'
link = 'Model-Link1.rvt'
view = 'Model-Federated-3DView1'
elements = FilteredElementCollector(link, view)

To get around this, as shown in many of the posts in the thread linked above, you can create a custom exporter by implementing the IExportContext interface which is used for things like exporting DWFx files. If anyone else here has any experience doing this in Python I’d like to know how, but I haven’t been successful in doing it myself.

Well, thank you, good information…

regards

gio