zoukankan      html  css  js  c++  java
  • 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;
        }
    }
    url:http://greatverve.cnblogs.com/p/get-all-element.html
  • 相关阅读:
    0102-进程操作(面向对象简单工厂模式,打开输入文件)
    0101-进程操作(变量命名)
    win10无法成功完成操作因为文件包含病毒或潜在的垃圾软件如何处理
    序列化和反序列化
    __slot__的用法
    python中typeguard包
    pandas如何将多个DataFrame写入同一个excel工作簿中
    DEAP库遗传算法
    【教程】如何把喜马拉雅音频下载到电脑
    oracle安装路径查看方式
  • 原文地址:https://www.cnblogs.com/greatverve/p/get-all-element.html
Copyright © 2011-2022 走看看