Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Linked Elements that Appear on Schedule Revit API

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
889 Views, 3 Replies

Get Linked Elements that Appear on Schedule Revit API

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?

3 REPLIES 3
Message 2 of 4
naveen.kumar.t
in reply to: Anonymous

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

 

Viewschedule API

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
Anonymous
in reply to: naveen.kumar.t

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).

Message 4 of 4
callumf
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community