This project test how the FilteredElementCollector with the filter VisibleInViewFilter with inverted enabled/disabled using the ricaun.RevitTest Framework.
The Project2021.rvt have 4 walls with floor plan view and 3D view.
The VisibleInViewFilter presents two issues:
- When the
invertedparameter is set totrue, the filter does not invert. This issue is reported in the Revit API Forum. - When using the filter, sometimes results in an empty collection, happens because elements geometry in the view is not loaded, is kinda similar with the issue with the view and link. RevitTest.FilteredLink.Tests
To force the elements geometry to be loaded in the view, you can use the FilteredElementCollector with the specific view. This will ensure that the geometry of the elements is loaded and can be accessed. Some filter is need the WhereElementIsNotElementType is used in the workaround.
// Force to load the elements in the view, this make the `VisibleInViewFilter` to work as expected.
new FilteredElementCollector(document, view.Id)
.WhereElementIsNotElementType();
new FilteredElementCollector(document)
.WherePasses(new VisibleInViewFilter(document, view.Id))
.ToElements();This is the same workaround used in the RevitTest.FilteredLink.Tests to avoid the crash.
This project is licensed under the MIT License.
Do you like this project? Please star this project on GitHub!