Pre-Delete Elements: Know What You're About to Delete



Hi all,

The question: how to know which elements would be deleted if I deleted a certain object in my model?
For instance, if I deleted a wall, can I get a list of its hosted objects which would also get deleted?

I’ve been looking for a Python version of this workflow for some time, so though I’d share.

Credit to @Deyan_Nenov for his macro version (I’ve just more or less transcribed it to Python) and to @Thomas_Mahon for various tips. Original macro can be found here:

The definition can be found here:

Element - Pre-Delete.dyn (8.1 KB)

Hopefully someone else finds it helpful!


Remove unused reference planes

Hey, I went ahead and changed the topic to Share since this is a solution and not a question.
Good work though!


Update: The Revit 2019 API now contains a method which will return the ElementIDs of dependent elements.

Posted under section 2.3 of this document:

As such, if you’re in 2019 you’ll be wanting to use this method instead of the Dynamo script posted above.




They actually added it in Revit 2018.1 update! :sunglasses: