Delete certain views from a project. Only certain ones being deleted


I am looking to use Dynamo to delete views prior to model issuing, I have a filter set-up to decide which shall be deleted and which shouldn’t. This section is working ok.

A lot of the elements are being deleted that should be, but also a lot that should be are not.

I am getting an error in Python for the deleting section stating:

“Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.

Traceback (most recent call last):

File “”, line 27, in

Exception: The referenced object is not valid, possibly because it has been deleted from the database, or its creation was undone”.

Line 27 is where it says:

I have tried adding a “unique items node” to make sure I am not trying to delete items more than once, but this still isn’t doing it.

Apologies if this isn’t the right place to ask this, I am not sure if the issue is within what I’m trying to do in python or something happening before that.

Has anybody got any ideas on what the issue could be?

I have attached the sample Revit file and dynamo definition for testing. The dynamo definition has a node within it for the python.


Are any of the views dependents of another view? If you delete the parent first and then try to delete the dependent you’ll get this error.

Thanks for the idea Sean, however the project doesn’t have any dependant views in at the moment.

Some nodes appear to be returning nulls for some reason, but this may be a graphical error in dynamo as further down the list filtering out the views to keep appears.

Is this a common display error, or could this be where my problem lies.


I think you are running into the same thing I did here. Your getting the nulls because the information a out the element is only presented after graph execution, which is after the element has been deleted. So, any node that has actual elements will display null while nodes that display text info may still appear to contain the information.

1 Like

Thanks Sean, that’s useful info to know.

I have switched the python node to a “delete elements node” from Archilab, this seems to work!

However, deleting so many elements at once seems to cause a crash, which is why I looked for python nodes to see if I could delete say a group of 10 at a time.

I have switched back to using a “delete element” python code I found in this thread. This seems to work also. So clearly my issue was within the python I was trying to use.

I think I need to go read this thread and understand it more before coming back to ask how to only delete a group of 10 elements at a time. If I need to do this and get stuck shall I make another thread?

Thanks again for the help.

Deleting elements using Python - Revit - Dynamo (

1 Like

Get All Views from Bakery gets Views well.

Here is my cleaner without any filters: