Retrieve all view templates

Does anyone have a custom node to retrieve all View templates.
Synthetic package has one but it does not work on Revit 2020.

I’m not sure why the node you’re using doesn’t work in Revit 2020, but if you paste this code into a Python node, it should work:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import FilteredElementCollector, View

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# Get all views in current document
views = FilteredElementCollector(doc).OfClass(View).ToElements()
# Return all views which are view templates
OUT = list(filter(lambda x: (x.IsTemplate), views))

This code first gets all views in the current document. Then, using the IsTemplate property of each View, it returns only views which are also templates.

2 Likes

Thanks cgartland but Im looking for a node that retrieves All View templates. I have some view templates that are not currently in views. Your scripts only gives me templates that are currently assigned to views only.

Edit: You could also package this as your own custom node.
This method will collect all view templates in your project regardless if it’s in use or not.

Hope this helps!

1 Like

cheers Patrick, This is what i wanted. legend.

1 Like

You’re very welcome!