Revit二次开发,WherePasses过滤器的使用

 View view = document.ActiveView;//活跃视图
            ElementId elementId = view.Id;
            FilteredElementCollector elements = new FilteredElementCollector(document, elementId);

房间过滤器RoomFilter ;

 RoomFilter roomFilter = new RoomFilter();
            List<Room> rooms = elements.WherePasses(roomFilter).Cast<Room>().ToList();
             foreach (Room item in rooms)
            {
                //删除房间标记,但是房间明细表里还是会存在,它的Location=null
                if (item.Level.Name.Equals("标高 2") && item.Location != null)
                {

                }
            }

元素相交过滤器BoundingBoxIntersectsFilter;

 //得到房间
            Room room = document.GetElement(new ElementId(555555)) as Room;
            //得到房间的编辑框
            BoundingBoxXYZ boundingBoxXYZ = room.get_BoundingBox(view);
            //通过编辑框创建一个outline
            Outline outline = new Outline(boundingBoxXYZ.Min, boundingBoxXYZ.Max);
            //得到元素边界过滤器
            BoundingBoxIntersectsFilter boundingBoxIntersectsFilter = new BoundingBoxIntersectsFilter(outline);
            //房间边界框相交(也边界框内的元素)的所有元素
            IList<Element> elements = collector.WherePasses(boundingBoxIntersectsFilter).ToElements();
            foreach (var item in elements)
            {
                if (item is Wall)
                {

                }
                if (item is FamilyInstance)
                { 
                
                }
                //类型是桌子  根据指定类型过滤
                if (item.Category.Id.IntegerValue == -2000080)
                { 
                
                }
            }

元素包含过滤器BoundingBoxIsInsideFilter;

元素类别过滤器ElementCategoryFilter等同于OfCategory;

   ElementCategoryFilter elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
            IList<Element> elements2 = collector.WherePasses(elementCategoryFilter).ToElements();

元素过滤器ElementFilter等同于OfClass()

新建QQ群:713878394

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值