Collecting Parameters/Elements from Linked Revit Models

Hello pyRevit community,

I just recently started writing scripts for my office about a month or two ago, so my experience is limited. My knowledge of programming is also fairly limited, I took a few classes in college but were mostly C++ and based around hardware integration.

One of the first scripts I wanted to write was an auto-demolish tool, where the script would automatically set the “Phase demolished” parameter to new construction for any elements that were hosted to a wall or element that also had the Phase demolished param as new construction. Since I am an MEP engineer we always use linked architectural models and the issue I have been having is collecting elements/parameter info from the linked arch models.

I put that script on pause and have focused on other ideas in the meantime, but I’m at the point now where I would like to go back and try to tackle this script. I don’t know if I am just not utilizing the correct part of the API or if I am just going about it the wrong way. Any information or advice would be greatly appreciated.

using the FilteredElementCollector constructor, you can pass it not only the actual document but also linked document and walk your way through the same way in the links

the logic goes:

from pyrevit import DB, HOST_APP
doc = HOST_APP.doc
collector_in_current_doc = DB.FilteredElementCollector(doc). ...

links_docs
for link_doc in link_docs:
    collector_in_link_doc = DB.FilteredElementCollector(link_doc). ...

Have a look at this master piece :rofl:

1 Like

I think you want the hostface of the MEP element in question.
public Reference HostFace { get; }

It will return a reference object that contains properties for the “LinkedElementId” (the id of the wall in the linked file) and “ElementId” (the RevitLinkInstance it’s attached to in the MEP model). You can get the linked Document by calling RevitLinkInstance.GetLinkDocument(), then linkedDocument.GetElement(LinkedElementId) to get the full wall object with its properties.

3 Likes

Jean-Marc,

Thank you for the response. I didn’t know it was as simple as just running the collector through the linked doc. When I have a little more free time at the office I will attempt to re-write the script with this in mind.

Martin,

I appreciate the response. This is precisely what I was attempting to do. Between your and Jean-Marc’s help I should be able to produce the script that I was hoping for. Thank you guys both, I will hopefully update sometime soon with a fully working script.