June 11, 2009

Unload Family Type

Question:
How can I use the API to remove unused family types from a project?
I know there is a command within Revit to do this, but we would like to automate the process.

Answer:
You can unload a specific loaded family symbol from your project using the Document.Delete() method.
I tested this as follows:

Load a specific column symbol "457 x 610mm".

Run an external command with the code below to filter out and iterate over all column elements, including symbols.

Apply the Delete method to remove and thus unload the specific symbol.

After running the code, the list of loaded family symbols displayed in the user interface confirmed that the specific family symbol was no longer present in the project.
Here is the code for the external command Execute method: