【Revit API】获取链接模型中构件

时间:2025-01-20 20:35:26

话不多说,直接代码

 var doc = commandData.Application.ActiveUIDocument.Document;
FilteredElementCollector linkInstances = new FilteredElementCollector(doc);
linkInstances = linkInstances.WherePasses(new ElementClassFilter(typeof(RevitLinkInstance))); if (linkInstances != null && linkInstances.Any())
{
foreach (RevitLinkInstance linkIns in linkInstances)
{
Autodesk.Revit.DB.Document linkDoc = linkIns.GetLinkDocument();
if (linkDoc != null)
{
//选取你想要的构件
}
}
}