简体   繁体   中英

How to get elements from links in Revit using macros with C#?

How can I get the elements from a certain category from a list of linked models into my project with a macro in C# language?. I apply a FilteredElementCollector and get the links, but then I'm unable to get the GetLinkedDocument to iterate over them and obtain the elements I'm trying to get. Hope that my question is clear.

//Get Document:
Document doc = this.Document;

//Get links:
FilteredElementCollector links = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks);

//Get elements:
string names = "";
foreach (Element e in links) 
{
    FilteredElementCollector coll = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PlumbingFixtures);
    names += coll + "\n" + "\n";
}

//Mostrar resultado:

TaskDialog.Show("Document", "Document Name " + "\n" + "\n" + names);

Here is a discussion of accessing lined element with several pointers to further related discussions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM