Skip to content

ricaun-io/RevitTest.FilteredVisibleInView.Tests

Repository files navigation

RevitTest.FilteredVisibleInView.Tests

Revit 2024 Visual Studio 2022 License MIT

This project test how the FilteredElementCollector with the filter VisibleInViewFilter with inverted enabled/disabled using the ricaun.RevitTest Framework.

Tests

The Project2021.rvt have 4 walls with floor plan view and 3D view.

Related Issues

The VisibleInViewFilter presents two issues:

  • When the inverted parameter is set to true, 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

Workaround

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.

Revit API Forum

License

This project is licensed under the MIT License.


Do you like this project? Please star this project on GitHub!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors

Languages