How to filter elements in the view range

How to filter elements in the view range

SimonaQQ
Advocate Advocate
1,155 Views
2 Replies
Message 1 of 3

How to filter elements in the view range

SimonaQQ
Advocate
Advocate

Hi All,

I am trying to find out all elements in a view range by FilteredElementCollector(Document, ElementId).

However, some elements outside the view range will still be passed.

So, how to get more precise results?

 

Revit officially offers a solution, but I don't know how to do it:

https://www.revitapidocs.com/2020/6359776d-915e-f8a2-4147-b31024671ee1.htm 

Elements that will be passed by the collector have graphics that may be visible in the input view. Some elements may still be hidden because they are obscured by other elements.

For elements which are outside of a crop region, they may still be passed by the collector because Revit relies on later processing to eliminate the elements hidden by the crop. This effect may more easily occur for non-rectangular crop regions, but may also happen even for rectangular crops. You can compare the boundary of the region with the element's boundary if more precise results are required.

Accessing these visible elements may require Revit to rebuild the geometry of the view. The first time your code constructs a collector for a given view, or the first time your code constructs a collector for a view whose display settings have just been changed, you may experience a significant performance degradation.

 

Can you help me?

Any help will be appreciated!

 

0 Likes
1,156 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

Maybe you can use the filtered element collector to preselect a candidate element set, and post-process them more precisely, e.g., using:

 

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

zefreestijl
Advocate
Advocate

Hi, I got a same question,
I've noticed there're VisibleInViewFilter and SelectableInViewFilter,

but both of them not worked as what I was looking for.

 

FilterOnlyVisible.jpg

I understand SelectableInViewFilter might not be working since I can still select items which are not visible outside a cropped region in Revit,

 

but why does VisibleInViewFilter still selects any invisible items?

then what's the difference between those two Filters?

 

Any idea how could I filter the visible elements as exactly as what I saw in current views?

 

Thanks.

0 Likes