So, you cannot purge view templates in ‘out of the box’ Revit. I have just learned recently. Probably I have never needed it before, but recently I did.
I have no idea why this function would be missing, but it is very easy to implement in API. You can use a C# macro manager for that perfectly fine, but somehow it seemed faster for me just to use a python node in Dynamo.
The procedure is simple. First you collect all the views (FilteredElementCollector). Then you loop through them and build a list of view templates that are in use.
Then you pick only views that actually are view templates and one by one you check whether they are present in the aforementioned list. If not, template is deleted.
That’s all. Dyn file and python script below.
import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import* clr.AddReference('RevitServices') from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument views = FilteredElementCollector(doc).OfClass(View) usedTemplateIds =  for v in views: if not v.ViewTemplateId in usedTemplateIds: usedTemplateIds.append(v.ViewTemplateId) allTemplateIds = [a.Id for a in views if a.IsTemplate] removedIds =  TransactionManager.Instance.EnsureInTransaction(doc) for id in allTemplateIds: if id not in usedTemplateIds: doc.Delete(id) removedIds.append(id) TransactionManager.Instance.TransactionTaskDone() OUT = removedIds