We talked about both quick (ElementQuickFilter) and slow element filters (ElementSlowFilter) earlier, now let’s look at how the Element Finder of the RevitAddWizard can automate the process of creating any combinations of various filters, quick or slow, invert or not, AND or OR, with argument or without, etc.
Think about such a very particular case, we’d like to find elements which:
• enclose a point represented by pointInBox0,
• and are not of category, OST_Site,
• and are not of type, Zone,
• or are of structural type, Footing,
• and are not owned by the view represented by idView4,
• and are not curve driven,
• and with design option as represented by idDesignOption6,
• and are not among some elements that are already known, represented by idsToExclude7,
• and are not of curve element type as ModelCurve,
• and are on a specific level represented by idLevel1,
• and meet a particular element parameter requirement represented by the filterRule2,
• or are family instances of Element idFamInstance3 in the Document doc,
• and are not in the primary design option member.
It sounds scary, doesn’t it?
With the Element Finder of the RevitAddinWizard on hand, all these look just trivial. Please just follow these instructions:
And you will get the following code to address the case for you in a moment:
public static List<Element> FindSomethingVerySpecial(RvtDocument doc, XYZ pointInBox0, ElementId idView4, ElementId idDesignOption6, ICollection<ElementId> idsToExclude7, ElementId idLevel1, FilterRule filterRule2, ElementId idFamInstance3)
{
List<Element> list = new List<Element>();
FilteredElementCollector finalCollector = new FilteredElementCollector(doc);
BoundingBoxContainsPointFilter filter1 = new BoundingBoxContainsPointFilter(pointInBox0, false);
finalCollector.WherePasses(filter1);
ElementCategoryFilter filter2 = new ElementCategoryFilter(BuiltInCategory.OST_Site, true);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter2));
ElementClassFilter filter3 = new ElementClassFilter(typeof(Zone), true);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter3));
ElementStructuralTypeFilter filter4 = new ElementStructuralTypeFilter(StructuralType.Footing, false);
finalCollector.UnionWith((new FilteredElementCollector(doc)).WherePasses(filter4));
ElementOwnerViewFilter filter5 = new ElementOwnerViewFilter(idView4, false);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter5));
ElementIsCurveDrivenFilter filter6 = new ElementIsCurveDrivenFilter(true);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter6));
ElementDesignOptionFilter filter7 = new ElementDesignOptionFilter(idDesignOption6, false);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter7));
ExclusionFilter filter8 = new ExclusionFilter(idsToExclude7);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter8));
CurveElementFilter filter9 = new CurveElementFilter(CurveElementType.ModelCurve, true);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter9));
ElementLevelFilter filter10 = new ElementLevelFilter(idLevel1, false);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter10));
ElementParameterFilter filter11 = new ElementParameterFilter(filterRule2, false);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter11));
FamilyInstanceFilter filter12 = new FamilyInstanceFilter(doc, idFamInstance3);
finalCollector.UnionWith((new FilteredElementCollector(doc)).WherePasses(filter12));
PrimaryDesignOptionMemberFilter filter13 = new PrimaryDesignOptionMemberFilter(true);
finalCollector.IntersectWith((new FilteredElementCollector(doc)).WherePasses(filter13));
list = finalCollector.ToList<Element>();
return list;
}
This case seems too complex and may not make sense at all for real applications, but the Element Finder of the RevitAddinWizard can do really simple, practical, and useful stuffs as well.
For example, if the following filters are filled in, exactly the same helper filter method FindAllRoofsCeilingsFloorsAndStairs_Approach1 as introduced in early posts will be created for you:
If the following filters are filled in, exactly the same helper filter method FindAllRoofsCeilingsFloorsAndStairs_Approach2 as introduced in early posts will be created for you:
If the following filters are filled in, exactly the same helper filter method FindAllElements as introduced in early posts will be created for you:
If the following filters are filled in, exactly the same helper filter method FindAllRoofsCeilingsFloorsAndStairs as introduced in early posts will be created for you:
Give the RevitAddinWizard a try and you will not feel regret.
Links to some related articles:
Manage Element Filters - ElementQuickFilter of Revit API
Recent Comments