Can i get current view getting linked elements?


i have here trouble… how can i get my rooms (linked doc) of my current view (doc) ?

#🌈 links
linked_docs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType().ToElements()
lnkInstance = [i for i in linked_docs if i.Name.Contains("FM_AR")]
doclnk = lnkInstance[0].GetLinkDocument()
title = doclnk.Title

# 🔆 Linkify setup
output = script.get_output()
linkify = output.linkify

# 1️⃣ Collector
elements = FilteredElementCollector(doclnk, doc.ActiveView.Id)\
element_ids = FilteredElementCollector(doclnk, doc.ActiveView.Id)\

i use also linkify…

I believe this is a Revit API limitation - its only possible in Revit 2024 and above

1 Like


good to know … so it is not my programming style :wink:

What’s the code at line 81 of the script? The error message says that you’re giving it an Id that is not the id of a view.

Quick tip: since you’re repeating a lot of code to retrieve the elements and their ids, you can save the element Collector in a variable and use it to call both ToElements and ToElementIds.that way you only create one object instead of two, saving memory and cpu time :wink:

1 Like

@sanzoghenzo ,

both it is not working either doc.ActiveView or doc.ActiveView.Id with linked Elements.

Oh, sorry, now I get what you’re trying to do.

You can find a similar discussion on the autodesk forum, you have to compute the coordinates of the view range and select the elements using a spatial query

1 Like

hi @andreasd811 , I’ve found a solution on the Dynamo Forum with a similar situation. I hope it can help you with this problem.
Filter Element from Linked Model only if visible in active view - Revit - Dynamo (