简体   繁体   English

如何使用带有 C# 的宏从 Revit 中的链接中获取元素?

[英]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?.如何使用 C# 语言的宏从链接模型列表中获取某个类别的元素到我的项目中? 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.我应用了 FilteredElementCollector 并获取了链接,但是我无法让 GetLinkedDocument 对其进行迭代并获取我想要获取的元素。 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.这是一个关于访问 lined element的讨论,其中包含一些指向进一步相关讨论的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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