The element filters:
pass elements whose actual 3D geometry intersects the 3D geometry of the target object.
With ElementIntersectsElementFilter, the target object is another element. The intersection is determined with the same logic used by Revit to determine if an interference exists during generation of an Interference Report. (This means that some combinations of elements will never pass this filter, such as concrete members which are automatically joined at their intersections, or site elements which are also excluded from interference checks). Also, elements which have no solid geometry, such as Rebar, will not pass this filter.
With ElementIntersectsSolidFilter, the target object is any solid. This solid could have been obtained from an existing element, created from scratch using the routines in GeometryCreationUtilities, or the result of a secondary operation such as a Boolean operation. Similar to the ElementIntersectsElementFilter, this filter will not pass elements which lack solid geometry.
Both filters can be inverted to match elements outside the target object volume.
Both filters are slow filters, and thus are best combined with one or more quick filters such as class or category filters.
Code region: using ElementIntersectsSolidFilter to match elements which block disabled egress to doors |
/// <summary> /// Finds any Revit physical elements which interfere with the target /// solid region surrounding a door.</summary> /// <remarks>This routine is useful for detecting interferences which are /// violations of the Americans with Disabilities Act or other local disabled /// access codes.</remarks> /// <param name="doorInstance">The door instance.</param> /// <param name="doorAccessibilityRegion">The accessibility region calculated /// to surround the approach of the door. /// Because the geometric parameters of this region are code- and /// door-specific, calculation of the geometry of the region is not /// demonstrated in this example.</param> /// <returns>A collection of interfering element ids.</returns> private ICollection<ElementId> FindElementsInterferingWithDoor(FamilyInstance doorInstance, Solid doorAccessibilityRegion) { // Setup the filtered element collector for all document elements. FilteredElementCollector interferingCollector = new FilteredElementCollector(doorInstance.Document); // Only accept element instances interferingCollector.WhereElementIsNotElementType(); // Exclude intersections with the door itself or the host wall for the door. List<ElementId> excludedElements = new List<ElementId>(); excludedElements.Add(doorInstance.Id); excludedElements.Add(doorInstance.Host.Id); ExclusionFilter exclusionFilter = new ExclusionFilter(excludedElements); interferingCollector.WherePasses(exclusionFilter); // Set up a filter which matches elements whose solid geometry intersects // with the accessibility region ElementIntersectsSolidFilter intersectionFilter = new ElementIntersectsSolidFilter(doorAccessibilityRegion); interferingCollector.WherePasses(intersectionFilter); // Return all elements passing the collector return interferingCollector.ToElementIds(); } |