Sample Code Revit Batch Processor 1.1.15 documentation
Bases: Base
Class constructor.
purgeTransactionName (str) – The name of the transaction to purge elements under.
purgeIdsGetter (func) – The function which returns all element ids to be purged
purgeReportHeader (str) – Human readable report header for each purge action
testReportHeader (str) – Human readable report header for each test action
testIdsGetter (func) – functions which returns all available type ids in model of same category as purge action. To be used to compare ids before and after code purge with ids before and after revit built in purge
This purge approach deletes an element from the model and checks whether that deletion changed any other elements. If not, means the element is unused and can be deleted.
Function to execute on DocumentChanged event and inspect the modified & deleted elements. An unused element will have 1 deleted element and 0 modified elements.
Rolls back the processing if any warning is encountered
failures_accessor (FailuresAccessor) – The failures accessor to process
process_result (Result
) – A Result class instance used to store any failure messages only
The result of the failure processing
FailureProcessingResult
This script will ascertain elements not used in your model and delete them. It deletes the elements one by one and checks if there is modified elements which indicates another element was using the element. The transaction is rolled back if there is a modified element.
IMPORTANT: This has flushed out some corrupt families with unresolvable geometry so it is advisable to run on a detached copy of your model first and rectify any family errors
Credit for this script goes to Autodesk forum user so-chong from the below forum post https://forums.autodesk.com/t5/revit-api-forum/check-if-linepattern-is-in-use/td-p/7435014
doc (Document) – The Revit document to purge line patterns from
DEBUG (bool) – Whether to print debug information or not. Optional. Defaults to False
Based on the building coder article: https://thebuildingcoder.typepad.com/blog/2022/03/purge-unused-and-the-autodesk-camel.html
Purges the document using the purge unused functionality of the eTransmit tool provided by Autodesk.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
Result class instance.
Purge status returned in result.status. False if an exception occurred, purge command returned False, unsupported Revit version, otherwise True.
result.message will contain the purge status.
On exception:
result.status (bool) will be False.
result.message will contain the exception message.