您的位置:首页 > 其它

RevitAPI: 如何从FamilyInstance获取所在的开关系统(Switch System)

2014-12-03 17:00 363 查看
有客户问道如何使用API创建开关系统(Switch System),

很遗憾,答案是:目前没有API可以创建。

客户继续问如何从FamilyInstance获取所在的开关系统(Switch System)。

答案:目前没有直接从FamilyInstance获取开关系统的方法,不像获取电气系统有这样类似的方法:FamilyInstance.MEPModel.ElectricalSystems。

但是我们有一个间接的方式,那就是过滤出所有的开关系统对象,然后找到包含这个FamilyInstance的开关系统。

filtering all switch systems and see if any switch system contains that family instance.

代码示例如下:

Element element = null; // the element to find switch system
var categoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_SwitchSystem);
FilteredElementCollector mepSystems = new FilteredElementCollector(RevitDoc);
mepSystems = mepSystems.WherePasses(categoryFilter).OfClass(typeof(MEPSystem)); ;
foreach (MEPSystem mepSystem in mepSystems)
{
foreach (Element member in mepSystem.Elements)
{
if (member.Id == element.Id)
{
//found
break;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: