Select views with filtered element collector

Hi I would like to get a list of views in a revit document. I want to use the filtered element collector for this. Is there a way to only select the views and not the viewtemplates?
The problem is that if I filter on class View or Viewplan it also gives the viewtemplates as a result (#3 in the list in the below screenshot). I only want the views (#5 in the list). Is there a way to filter this out with the element collector?
Also when I use the views node from dynamo I have to filter out the templates as a second step to only get the views. Which is possible but seems like a workaround.
Probably the templates are in the wrong category…

Yup, you can filter view templates out by using the view.IsTemplate property. For example…

views = [v for v in FilteredElementCollector(doc).OfClass(View).WhereElementIsNotElementType().ToElements() if not v.IsTemplate]

https://www.revitapidocs.com/2020/bd7d3469-dc89-93b7-1cb8-848fd4f38d65.htm

Thanks a lot!

| Daniel_Woodcock1
December 12 |

  • | - |

Yup, you can filter view templates out by using the view.IsTemplate property. For example…

views = [v for v in FilteredElementCollector(doc).OfClass(View).WhereElementIsNotElementType().ToElements() if not v.IsTemplate]

1 Like