Message 1 of 2

Not applicable
11-29-2019
08:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am a beginner of REVIT API.
Recently I have been writing a code that applies the filter rules in a short time.
Works well if only one filter rule is applied, such as the first capture.
However, the code for implementing a second capture, for example, does not work.
If a user-defined level exists, the user has created a code to add filter rules for it.
Is there a problem with my code?
thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | private ParameterFilterElement Pvt_CreateFloorLevelFilter( Document doc, string filterName, double value ) { ParameterFilterElement filter = null; ICollection<ElementId> categories = new List<ElementId>(); categories.Add( new ElementId( BuiltInCategory.OST_Floors ) ); // Level Offset Value Paramter ElementId param1 = new ElementId( BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM ); // Level Parameter ElementId param2 = new ElementId( BuiltInParameter.LEVEL_PARAM ); // Level of user select Level targetLevel = _form.Transfer_SelectedLevel(); var miliValue = UnitControl.Millimeters_To_Feet( value ); IList<FilterRule> rules = new List<FilterRule>(); // Set rule Level Offset FilterRule rule1 = ParameterFilterRuleFactory.CreateEqualsRule( param1, miliValue, Double_Epsilon ); rules.Add( rule1 ); // If there's user selected Level, add it if ( targetLevel != null ) { FilterRule rule2 = ParameterFilterRuleFactory.CreateEqualsRule( param2, targetLevel.Id ); rules.Add( rule2 ); filter = ParameterFilterElement.Create( doc, filterName, categories, rules ); return filter; } // If there's no user selected Level, apply only this rule else { filter = ParameterFilterElement.Create( doc, filterName, categories, rules ); return filter; } } | cs |
Solved! Go to Solution.