Delete all the used elements and Annotation used in a project

OK been searching and searching but I am only getting close to the solution. my problem that I have is that I am trying to create a script to select all of the elements (annotation and elements) that is used in a particular template only and delete them. (just the used elements)

My reason is that we work in 1 template and when the project starts we move to an always updated template) this keeps from having the same mistake if the project take time to start.

I tried using some of the posts but it take some time for example

I also want a safeguard on it so joe dumass doesnt run this on a live project so trying to only run on files called project1 (Name called when you start from a new template file and save).

here is what I have so far

working it out3.dyn (36.3 KB)

Are you looking for some nodes that can do that or also a custom Python script?
You can colllect all the element, then take only what are placed (used) at least once.
Sorry, maybe I don’t get the point

do you need all elements in the model delete?

Yes, but just the used items and only for a particular template file (I don’t want anyone to accidently delete all used elements in a working project.)

when you start a new project from a template it defaults to the name Project1 without a path. so I was thinking you could break the chain by looking if it has a path and stop the script if it cant find one. or just look for the name Project 1

P.S. I dont like the Quick delete because of the selection of the views anso deletes the views as well as the items

Thanks in advance

Can be both just trying to clean up a template for the linking in of new model elements from another project.

we have a template with placeholder elements. we then get a client to send us there Revit model that model then comes into out template. We manually delete the elements which doesn’t take much tome but I would like to automate the entire string and the first part is to delete the elements.

Why don’t clean the template? When you start a new project, it will already cleaned. Maybe I miss something

That is true but the way we use our templates is to have a placeholder box of elements to utilize our content to work on for the team. I am asking if there is a way in dynamo to do this not how you would do your template.

Not trying to be rude but you are not answering the question

Sure, don’t worry, simply I don’t understand well.
So, you can collect the boxes, read some property ( that tells you if to remove or not ), check if equal or not to your rule, filter the initial list with the bool mask then delete them.

I’d look at more than just Project1 as the second project created (even if you save the first as a new name or close without saving) becomes something other than project1. Taking the path into consideration is likely key.

But from here you can use an If node to pass your delete function if true, or a object identity function if false. Then use a function.apply node to run the function on your data set. Be sure to keep the inputs detached and disable any default inputs as needed.

1 Like

See if this can help? As I am a beginner, there could be a simpler way to write this script.

Result for Template file

Result for existing project file

working it out4.dyn (55.8 KB)

1 Like

That is perfect!! for the long way it takes about 90 seconds for the quick way it is instant (I only have to have the views set up in the template for it to look at. Awesome Thank you very much.

1 Like