打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Revit API取得全部元素
//取得全部元素
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdGetAll : IExternalCommand
{
    public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
    {
        UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
        //全部元素
        FilteredElementCollector collectorAll = new FilteredElementCollector(uiDoc.Document);
        collectorAll.WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilter(false), new ElementIsElementTypeFilter(true)));
        TaskDialog.Show("全部", collectorAll.Count().ToString());
        //IsElement
        FilteredElementCollector collectorIs = new FilteredElementCollector(uiDoc.Document);
        collectorIs.WherePasses(new ElementIsElementTypeFilter(true));
        TaskDialog.Show("IsElement", collectorIs.Count().ToString());
        //IsNotElement
        FilteredElementCollector collectorIsNot = new FilteredElementCollector(uiDoc.Document);
        collectorIsNot.WherePasses(new ElementIsElementTypeFilter(false));
        TaskDialog.Show("IsNotElement", collectorIsNot.Count().ToString());

        //数量
        int ductAll = 0;
        int ductIs = 0;
        int ductIsNot = 0;
        foreach (Element el in collectorAll)
        {
            if (el is Duct)
                ductAll += 1;
        }
        foreach (Element el in collectorIs)
        {
            if (el is Duct)
                ductIs += 1;
        }
        foreach (Element el in collectorIsNot)
        {
            if (el is Duct)
                ductIsNot += 1;
        }
        TaskDialog.Show("duct", ductAll + "," + ductIs + "," + ductIsNot);

        return Result.Succeeded;
    }
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
【新提醒】Revit二次开发 RevitLookUp安装说明
Revit开发
批量删除不需要过滤器
在Script中用程序控制谁能进入某个域
快速定位元素
学习4、Revit二次开发1:创建标高
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服