Delete Views From Revit Project


HI all,
I am hoping someone can help me with this. I have been playing around for a couple of hours now and have been going around in circles.
Basically, i want to delete all of the views in a project EXCEPT the views which have a certain parameter filled out. In this case, it is a parameter which is added to our views and we sort the project browser this way.
So, we have a parameter in our project called IDENTITY_PACKAGE_WF which is assigned to all views.
We have a series of views labelled 00 BASE VIEW in the above parameter and these are teh ones i want to keep.
So i have

  1. collected all of the views in the project
  2. Collected the views with the IDENTITY_PACKAGE_WF parameter
  3. Collected the views which have 00 BASE VIEWS applied to that parameter
  4. Used this to create a filter (list filter by bool mask), which gets me the 3 views i want to delete.Yay!
    I then use the delete elements, but as you can see, they are all null and nothing deletes.

Any idea what I am missing here? Im sure this could be done a lot more simply and if that is the case, I would really appreciated any help anyone can give me.

Make this change to your script, and it should work.

For your information you have been putting a string into a input that requires a revit element.

Edit: Omitted image as it was incorrect, correct image in below post.

HI Brendan,
I must have been looking at this for too long. I cant see what you have suggested for me to change?

Sorry i had uploaded the incorrect image

1 Like

No problem, just happy for the help!

Got it, and now and it works brilliantly.
I now see what you mean by a string into an element node. I couldn’t see the wood for the trees.

Thank you!