Purge Unused Via the API

Purge Unused Via the API

Anonymous
Not applicable
14,157 Views
25 Replies
Message 1 of 26

Purge Unused Via the API

Anonymous
Not applicable

So I've read this:

http://thebuildingcoder.typepad.com/blog/2013/03/determining-purgeable-elements.html

and this: 

http://forums.autodesk.com/t5/revit-api/writing-a-purge-utility/m-p/2735359/highlight/true#M1726

 

and they say that triggering the "Purge Unused" button under the "Manage" tab via code isn't possible and that you have to write your own code to handle the not so small task of doing it manually.

PurgeUnused.PNG (this button)

 

 

I also noted that both those posts are from around 3 years ago. I was wondering if there was an update on this. I can't find an API specific road map for features with a cursory google search, anyone know if there is one?

 

I don't want to rewrite code that already exists, especially when it sounds like it's a sizeable project in its own right! It's tantalizingly out of reach and replicating it would feel like time wasted.

 

Is it already in the API and I just can't find it? Are there plans to put it into the API if not? Should I wait for it to turn up in the API or grit my teeth and code my own solution? Should I just split my program and demand people press the button manually in the worst UX since MS-DOS?

 

 

 

Accepted solutions (4)
14,158 Views
25 Replies
Replies (25)
Message 21 of 26

RPTHOMAS108
Mentor
Mentor

I had a working version which was successful for years following the pattern:

Post the purge command

Respond to dialogue showing event with ok then Post the purge command.

It would do this a fixed number of times.

Since then been using @matthew_taylor approach with the performance adviser. Since it may not be what it's intended for but it works in a cleaner fashion and crucially you can do it for multiple files.

 

The limitation of the post purge command approach was that you exit the context after posting the command relying on dialogue showing to re-enter it and so you can't open another file.

 

Regarding materials and assets you could probably detect and remove those quite easily. Assets are related to materials and materials used can be found from each element remaining. Or you can iterate materials and find quantities used.

 

There were other items I think the performance adviser didn't cover that the purge did. 

Message 22 of 26

drawings4RALJ
Observer
Observer

@Martin.Servold_MEE 

Hi Martin, what'd you import for the List function on line 26?
I'm getting a 'List' is not defined error when I run the script in revit.

Thanks

0 Likes
Message 23 of 26

Martin.Servold_MEE
Contributor
Contributor

@drawings4RALJ 

from System.Collections.Generic import List

 

0 Likes
Message 24 of 26

drawings4RALJ
Observer
Observer

@Martin.Servold_MEE 

Thanks Martin, the script is running as intended now but unfortunately it purges everything except the 'Other Styles'  group... Is there any fix?

0 Likes
Message 25 of 26

Martin.Servold_MEE
Contributor
Contributor

@drawings4RALJ 
There's not a way that I know of to purge the other styles items.

Below is all the available options (and their Guids) for the performance adviser. You can try going through theses options.

View clipping is disabled - b37b2ae0-6eab-423d-bec7-59c5598d1c82
Interior categories are enabled in 3D view - 5d4c01d2-a2c7-40aa-a29e-f9669cf5aeaa
View detail level is too high - 10c1bac3-9b90-4772-8731-92ee7b9aca7b
Multiple non-overlapping loops - 3410389d-7ae7-4f04-9183-69cd9ef0df48
Sketch is too complex - f4fdc819-9044-4785-b5e3-5a36e89b9bd9
Sketch area too large - 90f0eae9-1840-436a-83fb-260f07d809db
Host contains too many inserts - b85b3b89-d2a3-415a-b289-258a21d58da1
Overlapping walls - cbb14baa-a57c-48ee-aab4-4137fcad779e
Too Large Family File - de12e3b2-92da-48f2-a893-b422cf78d6bc
Many Unused Nested Families - ad5ef4a1-78e7-4778-8390-cf095c20734a
Too Many elements in Family - 1827be73-62d8-468b-8553-7606450f401f
View specific imports in Family - 2f03ca4a-8959-44ed-b34e-8359931972a2
Duplicate instances - b341a0f3-a468-4fad-8b26-39237d8486e7
In-place family contains disjoined solids - 67c0ac52-376d-4a45-ad12-7d4df13f0b8f
Project contains unused families and types - e8c63650-70b7-435a-9010-ec97660c1bda
Room separation line is not joined - 86263995-19bc-4e17-9068-7974a46d0410
Too many area boundary lines - fc4d3f92-60b0-4bf7-aa07-ed88c23d591b

  

0 Likes
Message 26 of 26

skandregula
Participant
Participant

Thank you so much for this! It worked great but I can't seem to find a solution to purge materials and material assets. The link in your post doesn't explicitly mention anything about purging unused materials. I came across this post but it doesn't purge materials and material assets all at once.  I need to run it multiple times to purge everything completely. Just wanted to check if you know how to fix this issue or if you were able to purge unused materials some other way?