Trying to delete views based on parameter value

Hi - All views in my Revit project have a parameter called View Category. I want to delete all views that include “.E1” in the View Category.

I know the Elements.Delete node needs Elements for an input. However, if I connect it to the output from the All Elements of Category node, that doesn’t work either. I’m stuck…

Thanks

Right now you are feeding the delete node parameter values instead of views. Have another look at your graph and see if you can work it out :slightly_smiling_face:

1 Like

As you know, that you need to feed the element, not the parameter as an input, take a look here:

https://forum.dynamobim.com/t/cant-delete-views/

1 Like

If I make the change shown here, then I get an error in the boolmask node. (“Dereferencing a non-pointer”)

I would guess that the number of bools is not equal to your elements. You have to preserve the indices and probably also check your list levels in the list input at your „filter by bool mask“ Node. Do you really need the „list create“ and „list clean“ nodes?
Try connecting the „all elements of category“ directly to the „get parameter value by name“.

It‘s a lot easier to check whats wrong if you show the output of every node.

1 Like

Here’s something to consider:

First and foremost you are using Category > All Elements of Category to select all Views. That’s not a good idea, probably, since some unexpected things are “views”. Let me give you an example: Project Browser is considered a View in Revit. That’s not something you want to delete. So a better way to select views is using archi-lab.net nodes that let you filter by view type directly like so:

Now, I don’t have a sample file that has View Category parameter so instead I am going to demonstrate the workflow on Sheet Name parameter. Sheet Name is a parameter that would be filled in if given view was placed on a Sheet, otherwise it will be empty. So let’s say my intention here is to delete all views that are not on a Sheet. You can see that in the above image at index [0][3]. The field is empty.

Now in the above image pay attention to how I set up a filter for Sheet Name, Equals to “”. Then I use the FilterByBoolMask node to filter out Views, not Sheet Names, because the Delete node needs an element not a String.

Cheers!

-K

2 Likes

Konrad, Gerrit, Martin, thank you. See below. Success.

I also tried using the List.Equals node as Konrad did (instead of String.Contains), but that didn’t work for me. I have allot to learn…

Hello, I stumbled upon this post, and I was wondering, if you want to delete unused/unplanned views in the project browser, how will you do it.
image

I have tried to do it like this (inspired by Konrad:)), but it deleted the wrong views

It’s exactly what Konrad showed. Based on if the Sheet Name parameter has a value or not you know whether the view is on a sheet. That’s about all you can do. You can’t know if a view is “planned” for a sheet.

I have defined the parameter within the view instances, whether the view is in use, so if a user doesn’t intend to keep the view, it has no value. But if they want it kept, then how to delete the view contains no value?

Same way. You have to get that parameter value and check whether it’s empty ("") or not. Is “aaaaaa” the parameter you have filled out? Based on your screenshot Dynamo isn’t seeing a value for any of those views.

Also, make sure your list structures match. You don’t need the list levels on the List.Equals node as it’s now giving you a flat list. It’s probably better to use a == node anyway.

1 Like

Thank you Nick:)
I changed the List.Equals node to == which worked better.
Yes “aaaaaa” is my parameter, I ran the script again after I changed the nodes, and it know gives me value that says “aaaaaa”.

I see your point in that I have to get that parameter value and check whether it’s empty ("" ) or not.

1 Like