Using the Revit API (2017 and above), is there any way to get a list of linked elements that appear on a schedule (including filters, phase filters, etc).
Currently, if you query a ViewSchedule using the FilteredElementCollector, it will return N Elements (e.g. Windows, Doors, FamilyInstance) and M RevitLinkInstances. However, the RevitLinkInstance does not list out the actual Element that appears in the linked model. Is there a way to query a RevitLinkInstance in the scope of a ViewSchedule? Or a similar solution?
Hi @Anonymous,
You can get all the elements in Linked Document by using the below code
RevitLinkInstance RLI; foreach(Document D in app.Documents) { if(D.IsLinked) { FilteredElementCollector FamilyInstances = new FilteredElementCollector(D).OfClass(typeof(FamilyInstance)); IList<Element> LinkedElements = FamilyInstances.ToElements() as IList<Element>; foreach(Element element in LinkedElements) { //Do something } } }
For creating ViewSchedule refer the following Link
Thanks for your reply. Unfortunately, the method of provided returns ALL elements from that Linked Instance. What I am looking for is only the linked instances that are contained within the ViewSchedule (e.g. PhaseFilters, ScheduleFilters, DesignOption visibility, etc).
Hey Jacob,
I have managed to get it to work by passing the Schedule Id to a new fileteredElementCollector like this:
schedule = doc.ActiveView scheduledElements = list(FilteredElementCollector(doc, schedule.Id)) allElements = [] for element in scheduledElements: if element.Category.Name == 'RVT Links': linkedElements = list(FilteredElementCollector(element.GetLinkDocument(), schedule.Id)) for linkedElement in linkedElements: allElements.Add(linkedElement) else: allElements.Add(element) for element in allElements: print element
Let me know if that worked for you aswell