Model cleanup - Open in background

Hi everyone

I’m creating a dynamo graph to clean up models. Short summary of what i’m trying to do:

Open file --> audit, detach, preserve worksets
Clean up file --> delete certain sheets, delete all views not on sheets, delete and unload CAD links.
Save file and close --> compact file, save as central, is workshared, relinquish.

The file opens fine, saves and closes as well. But none of the actions I have assigned is completed. If I however perform the actions on an open document they work fine. Can anybody help me resolve this issue?

I would also love to add the ability to purge the document in the process. Not just once, but until 0 elements is left. I have seen a couple post for this, but none that did the trick for me.

Any help is much appreciated.

2 Likes

Hi @klausvm,

All the transactions must be done in the open document in the background.
In the picture of your graph, you are currently trying to clean the current document.
I hope that makes sense.

1 Like

Almost worked like a charm. For some reason it leaves behind 1 of the sketch sheets…

Does anyone know how to implement a purge function? I’v tried with the one from the Orchid package (@erfajo), but it returns an error
“Warning: Document.Purge operation failed.
The managed object is not valid.”

I have also tried with this Python script: https://gitlab.com/MattTaylor/RevitPurgeUnused/tree/master

Hi @erfajo

I got it working now. Didn’t connect it properly in the first place. It does however not completely purge the document, there are still some items left when I open the document afterwards.

there are several items you cant delete there must always be 1 view
always 1 floor
always 1 wall
and more

1 Like

Hi @klausvm,

Can you please let me know the name and package of the node you use here:

Capture

Hi,

You can find this node in the Genius Loci package.

2 Likes

@Alban_de_Chasteigner

Thanks so much! This is a very useful package!

1 Like

Hi everyone.
This is a great script for processing multiple files in a background very fast thanks to @klausvm
I have used it in a similar way but I have been trying to delete All 3d view templates and no good solution yet.
I found a great python script that does it for you but in a current Revit document so pretty useless if needed to be used a part of this cleaning script.

I think this scripts is @Konrad_K_Sobon ( thank you so much for publishing - it works great!)
Anyone has any ideas how to adjust this script to be able to read another revit file ( I have very limited or no python skills and need this being resolved asap)

I cant seem to get this to work. Please ignore the 2 nulls. Even without them I get this error