Use dynamo to Delete All View Templates

I’m currently looking for a way to delete all view templates from my model as easily as possible. I dont see myself deleting 100+ view templates one by one. I’ve managed to create a script to delete all filters but not one for deleting view templates. Could anyone advise?

1 Like

There is a custom node from Clockwork package called “View.IsViewTemplate” use that to filter all your views thay contains view template. Then you can delete view templates which are not assign to views. Good Luck!

Thanks Kulkul,

I don’t just want to delete the ones not in use, I want to delete all. I can’t seem to figure it out. Is there a way then to remove all templates from my views then delete all templates not in use?

What do you mean by {“Is there a way then to remove all templates from my views then delete all templates not in use”}

What is your end goal? Delete all view templates or delete which one not in use?

To collect all view templates do this:

List<View> vtList = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument)
                .Where(x => x.IsTemplate)

Then to delete it you will have to make a list of their Ids and do this:


Once you delete all view templates I don’t see how they would need to be removed from a view. There no longer will be anything applied to views. It doesn’t mean that your visibility settings will reset. They will stay the same as they were based on last view template applied. This behavior is the same with UI.

1 Like

To delete all templates.

Thanks Konrad.

Just to check, the script, where do I insert this. I’m new to dynamo and have really only done the visual programming part. Plugging the code in will work too, I just need to know where to put it. I appreciate the help.

Ahh, in that case just run this code. I assumed you would know how to translate that to Python or ZeroTouch node. My bad.

# Copyright(c) 2016, Konrad K Sobon
# @arch_laboratory,

# Import DocumentManager and TransactionManager
import clr
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

if IN[0]:
		errorReport = None
		allViewTemp = FilteredElementCollector(doc).OfClass(View).ToElements()
		toDelete = []
		for i in allViewTemp:
			if i.IsTemplate:

		# if error accurs anywhere in the process catch it
		import traceback
		errorReport = traceback.format_exc()
	errorReport = "Set input to True"
#Assign your output to the OUT variable
if errorReport == None:
	OUT = 0
	OUT = errorReport


Thanks @Konrad_K_Sobon. I ran it, however I did get a response:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
File “”, line 34


SyntaxError: unexpected token ‘TransactionManager’

Ahhh the formatting got a little screwed up when I pasted it. Make sure that TransactionManager.Instance.EnsureInTransaction(doc) has the same indentation as TransactionManager.Instance.TransactionTaskDone() so hit TAB twice for the latter.

Hopefully this is the final problem. I made sure I deleted the indentation on both, then put 2 tabs in on both lines. But got the following… @Konrad_K_Sobon you’re a great help!!!

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
File “”, line 38


SyntaxError: unexpected token ‘’

no, the idea is that they are in the same line together like this:

1 Like

I think that is what I did. Tell me if im missing something.

looks good now make sure they are TABS and not SPACES. Python is sensitive about this.

I’ve done eveything as you’ve said. Still no luck. I’ll try again on monday. Thanks again.

just take this. viewTemp.dyn (3.0 KB)


It’s best to delete the templates in code as Konrad suggested because currently 3d view templates can not be wrapped to a Dynamo object. Tho if you don’t mind deleting said 3d templates manually, you can use the following nodes as an alternative:


Worked like a charm. I’ll check where mine went wrong the first time. You’re a legend. Thanks for the help.

Great Job…Again

Both methods work fine. However would it be possible to only delete the templates not in use?