EaBIM一直以来积极响应国家“十二五”推进建筑业信息化的号召,对建筑领域的信息技术开展深入技术交流和探讨!致力于打造“BIM-建筑师-生态技术”三位一体综合资源交流共享平台,希望为BIM与可持续设计理念及技术的普及做出微小的贡献!!!

EaBIM

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 596|回复: 1
打印 上一主题 下一主题

ElementSlowFilter-慢速过滤器

[复制链接]

1514

主题

7465

帖子

1万

积分

admin

Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10

积分
12404

社区QQ达人

跳转到指定楼层
楼主
发表于 2014-1-9 12:29:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
We talked about the quick filters (ElementQuickFilter) in the previous post. In this article, we will discuss something about the slow filters (ElementSlowFilter).

Slow filters include:

• RoomFilter
• RoomTagFilter
• AreaFilter
• AreaTagFilter
• CurveElementFilter
• ElementLevelFilter
• ElementParameterFilter
• FamilyInstanceFilter
• SpaceFilter
• SpaceTagFilter
• PrimaryDesignOptionMemberFilter
• FamilyStructuralMaterialTypeFilter
• StructuralInstanceUsageFilter
• StructuralMaterialTypeFilter
• StructuralWallUsageFilter

We have discussed the differences and their similarities between the slow filters and the quick filters and even in the same group, so we will not repeat here. Now let’s look at a specific case, how to create some filters and a final FilteredElementCollector to collect all rooms, areas, spaces and their tags back, and they should be in the primary design option.
To achieve this goal, quite a few different kinds of slow filters seem necessary: RoomFilter, RoomTagFilter, AreaFilter, AreaTagFilter, SpaceFilter, SpaceTagFilter and PrimaryDesignOptionMemberFilter. We use them in the following code example to demonstrate slow filters:
        public static List<Element> FindRoomsAreasSpacesAndTheirTags(RvtDocument doc)
        {
            List<Element> list = new List<Element>();
            FilteredElementCollector finalCollector = new FilteredElementCollector(doc);
            RoomFilter filter1 = new RoomFilter();
            finalCollector.WherePasses(filter1);
            RoomTagFilter filter2 = new RoomTagFilter();
            finalCollector.UnionWith((new FilteredElementCollector(doc)).WherePasses(filter2));
            AreaFilter filter3 = new AreaFilter();
            finalCollector.UnionWith((new FilteredElementCollector(doc)).WherePasses(filter3));
            AreaTagFilter filter4 = new AreaTagFilter();
            finalCollector.UnionWith((new FilteredElementCollector(doc)).WherePasses(filter4));
            SpaceFilter filter5 = new SpaceFilter();
            finalCollector.UnionWith((new FilteredElementCollector(doc)).WherePasses(filter5));
            SpaceTagFilter filter6 = new SpaceTagFilter();
            finalCollector.UnionWith((new FilteredElementCollector(doc)).WherePasses(filter6));
            PrimaryDesignOptionMemberFilter filter7 = new PrimaryDesignOptionMemberFilter(false);
            finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter7));
            list = finalCollector.ToList<Element>();
            return list;
        }
The call to the method and some test code look like:

                List<Element> elements = ElementFinder.FindRoomsAreasSpacesAndTheirTags(CachedDoc);
                MessageBox.Show(string.Format("{0} rooms, areas, spaces and their tags in the PrimaryDesignOption are found in the model.", elements.Count.ToString()));
By the way, the above code likely will report zero elements found in some models since those rooms, areas, spaces and their tags may not be in the primary design option at all. So as to exercise the PrimaryDesignOptionMemberFilter, please make sure some elements are really using it.
Last but not least, the same task can be completed by some other filters, preferably quick filters like the ElementCategoryFilter and/or the ElementClassFilter. And even for the seemingly very special PrimaryDesignOptionMemberFilter, the ElementParameterFilter one can be a replacement, I believe. The alternative (maybe better/quicker) approach will not be demonstrated in detail here, but you can take it as an assignment if you like.
Do not worry about all the different kinds of filters and their arguments, quick or slow, theRevitAddinWizardwill help you generate any combinations of the filters and their arguments in a moment.

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 反对反对
工作时间:工作日的9:00-12:00/13:30-18:00,节假日不在线,请勿留言

4

主题

851

帖子

1307

积分

BIM经理

Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6

积分
1307
2F
发表于 2014-2-20 14:59:21 | 只看该作者
顶...... 楼下跟上.....
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|EaBIM网 ( 苏ICP备2020058923号-1  苏公网安备32011502011255号

GMT+8, 2024-11-16 19:05

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表