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

萧闫子 发表于 2014-1-9 12:17:50

ElementParameterFilter: Using FilterIntegerRule to Filter Element Parameters in

Let us continue to talk about the particular slow filter in Revit API, ElementParameterFilter.   
Let’s look at how to use the FilterIntegerRule filter rule to filter integer type element parameters in this article. Supposing we’d like to find all walls which bind some rooms, what shall we do?
The following code does so in C#:public static ICollection<ElementId> GetWallsRoomBound(RvtDocument doc)
{
    ParameterValueProvider provider = new ParameterValueProvider(new ElementId((int)BuiltInParameter.WALL_ATTR_ROOM_BOUNDING));
    FilterIntegerRule rule = new FilterIntegerRule(provider, new FilterNumericEquals(), 1);
    ElementParameterFilter filter = new ElementParameterFilter(rule);    return (new FilteredElementCollector(doc)).OfClass(typeof(Wall)).WherePasses(filter).ToElementIds();
}

A few highlights about the code:• An ElementParameterFilter needs a filter rule, the FilterIntegerRule in this case.
• The FilterIntegerRule needs a parameter value provider (ParameterValueProvider) and a filter rule evaluator (FilterNumericRuleEvaluator), specifically the FilterNumericEquals.
• The FilterIntegerRule also needs a value for the integer parameter to compare with.
• The ParameterValueProvider needs an argument of parameter, as the wall room bounding parameter BuiltInParameter. WALL_ATTR_ROOM_BOUNDING in this case.
• The parameter is represented by an ElementId, which is the numeric value of the specified BuiltInParameter.
• A fast filter, ElementClassFilter, represented by its shortcut method (OfClass), is also used to narrow down the FilteredElementCollector first. It not only speeds up the search but also makes sure only walls are returned.Curious people may ask: how did you figure out the WALL_ATTR_ROOM_BOUNDING of the BuiltInParameter enumerator is the right one to use as there are tons of built-in parameters there?Good question! Though we still have to make some guess and do some experiment most of times to sort things like this out, a few RevitAddinCoder coders can help make the task a lot easier:• Parameter Infoer Coder
• Parameter Categorizer Coder
• Parameter Retriever CoderTo use the method is very straightforward. Here is some test code in C#:…
ICollection<ElementId> ids = GetWallsRoomBound(CachedDoc);
TaskDialog.Show("ElementParameterFilter Test", string.Format("{0} walls are binding rooms.", ids.Count));

妮可 发表于 2014-3-13 12:10:42

路过!!!
不发表意见……

levin 发表于 2014-3-13 12:05:12

路过!!!
不发表意见……

dison 发表于 2014-3-14 11:01:03

路过!!!
不发表意见……

宇航员 发表于 2014-2-20 15:03:53

路过!!!
帮顶……

莞人莞事 发表于 2014-3-10 17:21:57

顶!!!!!!!!!!

飞天舞 发表于 2014-3-11 10:28:27

了解下BIM.....

月之影 发表于 2014-3-11 10:30:49

谢谢!!!
帮顶……

沧海冷月 发表于 2014-3-11 10:35:34

非常感谢!!

順順 发表于 2014-3-11 10:36:22

非常感谢!!

欧宝 发表于 2014-3-13 12:00:34

顶!!!!!!!!!!!!!!!!!!!!!!!!!

风吹枫落 发表于 2014-3-13 12:15:22

顶起来…………

爬爬``PA 发表于 2014-3-13 12:26:28

顶!!!!!!!!!!

大奔KY 发表于 2014-3-13 12:30:50

顶......
楼下跟上.....

卡巴kala 发表于 2014-3-14 10:56:09

(*^__^*) 嘻嘻……
页: [1] 2 3 4
查看完整版本: ElementParameterFilter: Using FilterIntegerRule to Filter Element Parameters in