Delete Viewport Type Issue

I created a script to delete unused viewport types and while it works, it also deletes random views that are not even using the viewport that is being deleted. Does anyone know what might be causing this?

Do you want to delete certain views or viewports from sheets?

Kind regards,


I am not trying to delete anything from sheets, I am just trying to delete the viewport type that is not being used. I am aware if I delete the viewport type and it is being used it will also delete the view that is using that viewport, however for some reason when I delete the unused viewport it deletes other views that are not even using that type.

1 Like

Hi Matthew,

I’ve come to the conclusion i didn’t get your question the first time. I will do some experimenting and will let you know what i found out. may i ask why you feel the need to delete viewport types? do you have that many?

Kind regards,


Please check if the following code works for you.
the input has to be a string containing the correct viewport type name e.g. : “view name”.
credits to: @awilliams

import clr
from Autodesk.Revit.DB import *
import Autodesk

import Revit

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc			= DocumentManager.Instance.CurrentDBDocument

string = (IN[0])

bip 		= BuiltInParameter.ALL_MODEL_TYPE_NAME
provider 	= ParameterValueProvider(ElementId(bip))
evaluator	= FilterStringEquals();
rule 		= FilterStringRule(provider, evaluator, string , True);
filter		= ElementParameterFilter(rule);
viewport 	= FilteredElementCollector(doc).OfClass(ElementType).WherePasses(filter).ToElements()


for i in viewport:


OUT = []