Filter to find views that support visibility

Filter to find views that support visibility

david_rock
Enthusiast Enthusiast
793 Views
4 Replies
Message 1 of 5

Filter to find views that support visibility

david_rock
Enthusiast
Enthusiast

Hello,

I am looking for a filter that will find all views that support visibility.

for each of the views that I find I want to apply IsFilterApplied(id). However this thows an exception if I try to call on some viewtypes. 

 

                Dim objFilteredElementCollector1 As FilteredElementCollector = New FilteredElementCollector(objDocument)
                objFilteredElementCollector1.OfClass(GetType(DB.View)).Cast(Of DB.View).Where(Function(v) _
                                                                                                   v.ViewType <> ViewType.ProjectBrowser And
                                                                                                   v.ViewType <> ViewType.SystemBrowser And
                                                                                                   v.ViewType <> ViewType.Schedule And
                                                                                                   v.ViewType <> ViewType.PanelSchedule And
                                                                                                   v.ViewType <> ViewType.PresureLossReport And
                                                                                                   v.ViewType <> ViewType.ColumnSchedule And
                                                                                                   v.ViewType <> ViewType.LoadsReport)
                Dim ListOfViewElementId As List(Of ElementId) = objFilteredElementCollector1.ToElementIds()

Any ideas?

Kind regards

David

 

0 Likes
Accepted solutions (1)
794 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

A typo? A missing 's' in 'PresureLossReport'?

 



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

0 Likes
Message 3 of 5

david_rock
Enthusiast
Enthusiast

Haha, no that's not it. It is the viewtype Enum which is incorrectly spelled.

ViewType Enum.png

 

Any other ideas?

Message 4 of 5

FAIR59
Advisor
Advisor
Accepted solution

The check View.CanUseTemporaryVisibilityModes() might do the trick.

 

IEnumerable<View> views = new FilteredElementCollector(doc)
				.OfClass(typeof(View))
				.Cast<View>()
				.Where(v=>v.CanUseTemporaryVisibilityModes());
0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

Cf., Get all Views that accept View Template:

 

https://forums.autodesk.com/t5/revit-api-forum/get-all-views-that-accept-view-template/m-p/9102739

  



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