Purge/Delete unused elements

is this possible using dynamo?

I would like to automate this up until the number of unused elements is 0

Many thanks

1 Like

There is a parable command for it, so I believe so. Gonna take some api/python work though.

Hello Jacob,
Thanks for your comment
Can you point me on any direction?
Have you seen this topic before in the forum?

I believe @jacob.small meant a Postable Command, which executed in Dynamo via Python would open up the “Purge Unused” window the same way as opening it up in Revit. I don’t believe there is any direct way to execute the commands within the Purge Unused dialog.

If you wish to discover and purge unused elements via Dynamo you would likely have to use some deductive logic to collect all elements of all categories and compare their element types to all element types in the project (family types and system types). The package Modelical has the nodes “Delete UnusedViewTemplates” and “Delete Unused Filters” and the package SteamNodes has a node “Tool.UnusedTypes” - these nodes could also be of use.

I’m not sure if you could quite discover all of the unused elements that the Revit Purge Unused method discovers (materials and some styles i.e. arrowheads, etc.). I’m curious of your reason for wanting to do this in Dynamo rather than the Revit OOTB way?


Thanks Amy,
We would like to automate purge with another def that delete views, sheets, dwgs and links.
I was surprised when I could not seen people talking about this in the forum.
Purging files everytime we need to do a model exchange up until the number of unused elems is 0 take a bit of time and if we can automate it muuuuch better, dont you agree???

Can you elaborate on this? The “Purge Unused” command in Revit doesn’t eliminate views not on sheets, etc. so do you mean View Types? Placeholder sheets? DWGs and Links that are not being used somehow…?

I agree it could be faster to eliminate everything all at once, rather than having to purge multiple times, but I also do not think that it would be simple or even entirely doable to find all the unused element types that the OOTB method catches

Hi Amy what I mean is that we have a dynamo def that delete views, sheets,etc…
We would like that def to include after deleting to purge the unused content
I hope this is clear

1 Like

I do think the OOTB Revit method would be most effective for catching all of the unused elements but if you do wish to try and automate it then what I described above would be the direction to take:

Have a look at the logic in the internal contents of the SteamNodes node Tool.UnusedTypes that I mentioned above as an example. Again, though, I believe there will be unused element types that would be difficult to identify in Dynamo i.e. the items that appear under “Other Styles” in the Purge Unused dialog

Better still would be to switch to a BIM360 workflow to eliminate the need for the exchange to begin with - everyone has access to everything as needed when needed. :wink:

The SteamNodes Tool.UnusedTypes would be a great starting point for catching a lot of the stuff you’d be looking to purge out. Might be that you can’t get any closer to a truly ‘automated’ effort than running a few of those in succession without getting into executing commands via journals.

My thought with the postable command (thanks @awilliams for understanding my poor spelling) was that kicking off the dialog automatically and repeatedly until the user hits an “all clear” button or you somehow pull a report that indicates no content was removed should be enough of an automation. Personally I feel that you want some degree of “ok what changed” when doing this sort of stuff anyway, so having the user hit ‘ok’ a few times and see the list of ‘checked items’ isn’t necessarily a bad thing.


I do remember having an autodesk plugin that would cleanup my files before sharing it with others. The purging an deleting of views/sheets was an option there. It’s a few years back, but one would think all commands used would be in the API or there was a method of doing such.

We have an automated cleaning process that does pretty much everything but the purge. We still have to do that manually - it’s just the most reliable and practical method.

However, because it’s not dependent on anything project related you might be able to set up a Revit log file that Dynamo could run. Haven’t tried it but it might work.

I think you can initialize the purge unused by utilizing the command “PostCommand” with a “RevitCommandId.LookupPostableCommandId(PostableCommand.PurgeUnused)” as input.

Though i am unsure how you could suppress the dialog box to automatically click purge/Ok as i think this is limited to how dynamo is linked into revit and what it can/cannot access as a process so you probably cannot access/do the final step of automating the actual dialog box.



I dont know if this will help, i got this after loading


Hi Rijsmus,
What package is that?

It’s not a package, it’s what they call a dynamic link library or dll.
Go to File, there is a command import library.
I don’t know if it will work.
It’s a bit too simple i think, to just expect it will work.
It might damage your Revit file, who knows


@Marcel_Rijsmus can you show me the graph how this works? for purged unused ?

I have not tried it

its a one click operation in revit, why automate it?

Maybe this could work


i have to purge unused until it becomes 0 purge items.

It is 4-5 time repeated process.
if you could help with some script that would be helpful .

Any Python script for Purged unused?

The same question was asked yesterday :