Surface visibility

Surface visibility

AndrewButenko
Advocate Advocate
565 Views
2 Replies
Message 1 of 3

Surface visibility

AndrewButenko
Advocate
Advocate

Hi!

 

I check visibility of surface with code:

 

surface.IsHidden(doc.ActiveView) 

But I have a surface that is not visible in the view. At the same time, the previous code returns "False."
The fact is that this surface is hidden by "Visibility/Graphics..." filter, like a screen:

 

vv.png

How do I identify such surfaces?

0 Likes
Accepted solutions (1)
566 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

I believe one solution is to run them through the custom exporter. That will report the results you also see on the screen, including all view settings.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 3

AndrewButenko
Advocate
Advocate
Accepted solution

Hi Jeremy!
Looks like I found the solution myself. I use the following code:

 

 Public Function IsElementVisibleInView(View As View, el As Element) As Boolean

' Obtain the element's document Dim doc As Document = el.Document
Dim elId As ElementId = el.Id ' Create a FilterRule that searches for an element matching the given Id Dim idRule As FilterRule = ParameterFilterRuleFactory.CreateEqualsRule(New ElementId(BuiltInParameter.ID_PARAM), elId) Dim idFilter = New ElementParameterFilter(idRule) ' Use an ElementCategoryFilter to speed up the search, as ElementParameterFilter Is a slow filter Dim cat As Category = el.Category Dim catFilter = New ElementCategoryFilter(cat.Id) ' Use the constructor of FilteredElementCollector that accepts a view id as a parameter to only search that view ' Also use the WhereElementIsNotElementType filter to eliminate element types Dim collector As FilteredElementCollector = New FilteredElementCollector(doc, View.Id).WhereElementIsNotElementType().WherePasses(catFilter).WherePasses(idFilter) ' If the collector contains any items, then we know that the element Is visible in the given view Return collector.Any() End Function
0 Likes