We discussed the loading of a single family type just two days ago. Here is a related question that came up and was handled by Saikat Bhattacharya:
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:
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:
public IExternalCommand.Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements ) { Application app = commandData.Application; Document doc = app.ActiveDocument; Filter filter = app.Create.Filter.NewCategoryFilter( BuiltInCategory.OST_Columns ); ElementIterator it = doc.get_Elements( filter ); while ( it.MoveNext() ) { Element e = it.Current as Element; if ( e.Name.Equals( "457 x 610mm" ) ) { doc.Delete( e ); } } return IExternalCommand.Result.Succeeded; }
Thank you Saikat for this solution!