美文网首页
Revit过滤器

Revit过滤器

作者: Karel_ | 来源:发表于2017-09-02 00:24 被阅读55次

1.过滤器

1.1ElementClassFilter​
ElementClassFilter的作用是根据类,来过滤Revit文档中的元素,即获取到符合传入类的元素。ElementClassFilter的构造函数定义是:ElementClassFilter(Type type)​​。

使用实例:

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;

            FilteredElementCollector collector = new FilteredElementCollector(doc);//建立收集器

            ElementClassFilter classFilter = new ElementClassFilter(typeof(Wall));//利用ElementClassFilter对收集器进行过滤
            collector = collector.WherePasses(classFilter);

            //将过滤得到的图元转换为id
            IList<ElementId> elid = new List<ElementId>();
            foreach (Element el in collector)
            {
                elid.Add(el.Id);
            }
            //将图元设置为选中状态
            uidoc.Selection.SetElementIds(elid);

            return Result.Succeeded;

        }
测试结果

1.2ElementCategoryFilter​​
ElementCategoryFilter即元素类别过滤器。Category(类别)!所有基类为Element类的元素都拥有一个Category属性用于表示这个元素属于的类别或者子类别,详见上一篇数据结构。

  ElementCategoryFilter​​ categoryFilter = new ElementCategoryFilter​​(BuiltInCategory.OST_Walls);//将元素的类别作为传入参数来过滤元素
            collector = collector.WherePasses(categoryFilter);

元素的类别可以采用如图方法查看:

查看元素类别 测试结果

2.选择过滤器
在执行命令的过程中,让用户自行选择构件或构建集。

主函数中的实现:
ISelectionFilter WallFilter = new WallSelectionFilter();
            IList<Reference> elementList = uidoc.Selection.PickObjects(ObjectType.Element, WallFilter, "选择墙");
接口的实现:
public class WallSelectionFilter : ISelectionFilter
    {
        public bool AllowElement(Element elem)
        {
            if(elem is Wall && elem.Name == "常规 - 200mm")
            {
                return true;
            }
            return false;
        }

        public bool AllowReference(Reference reference, XYZ position)
        {
            return false;
        }
    }
选择过滤器

相关文章

  • Revit二次开发 - 过滤器

    2.2选择过滤 2.2.1 选择过滤器 在Revit中,经常需要通过鼠标选择一个或多个构件,Revit API 提...

  • 过滤器

    过滤器分为过滤器和选择过滤器,主要用来批量选择Revit文档里的我们所需要的图元。 下面我们开始演示过程,首先建立...

  • Revit过滤器

    视频连接v.bimcc.com/course/35/tasks 常用过滤器:过滤器、选择过滤器 一、过滤器 建立一...

  • Revit过滤器

    1.过滤器 1.1ElementClassFilter​ElementClassFilter的作用是根据类,来过滤...

  • 05.Revit2016二次开发(基础篇)——访问element

    在Revit的项目中如果创建了好多的对象的情况下,若想选中特定的对象时,我们一般采用过滤器; 一、在工程中: 如图...

  • 问题:Revit样例文件的三维没有颜色

    问题:Revit样例文件中的默认三维空间没有颜色 问题原因:该三维视图应用了阶段化过滤器 解决方案:1.在视图属性...

  • Autodesk Revit Architecture 2019

    Autodesk Revit Architecture 2019标准教程revit建筑软件操作教程 Autodes...

  • revit漫游

    revit小白,项目报奖,需要准备几个revit漫游镜头。以最简单的一个镜头为例,记录revit漫游操作。镜头要求...

  • Revit速博插件「Extensions」免费下载附安装教程

    Revit Extensions 又称Revit速博插件包,是一款可以与Revit配套使用的增强工具包,这个插件包...

  • 参数化族其实没那么难

    Revit公式的应用 Revit中的公式为参数化建模提供了很大方便。那么关于revit中的公式,你知道的有多少呢?...

网友评论

      本文标题:Revit过滤器

      本文链接:https://www.haomeiwen.com/subject/vhkljxtx.html