Erase or delete the Loaded families inside revit

I created a script to load 10 families all at one once into revit and i made successfully run it. Now i would like to erase those families inside the revit with an another dynamo script. someone guide me the steps to do it.

Hola amgio buenos dias!
The node you are looking for is Element.Delete that is the easy part, the hard part is to select the elements you want to delete you need to select them and sometimes you have to filter between the different types of each family, the easy option is to select the family from the Project Browser and then delete them.

1 Like


The list of families that are currently loaded inside the revit project environment. Now i want to delete all those families just inside the revit coming from that directory in my local drive. I am completely stuck. Please help or let me know if i could provide you some more info.

Nothing happens after running the script…Not sure where i am making a mistake.

Are you wanting to delete only the placed instances of those families or completely remove the families and types from the project? What’s the reasoning for loading a family and then immediately deleting it?

As for why it’s not deleting, it’s likely because you’re loading the family and attempting to delete it all within the same transaction. The family won’t be loaded until after Dynamo runs, at which point it will have already tried to delete the elements. Adding a Transaction node between FamilyInstance.ByPointAndLevel and Element.Delete should get around this.

@chitru_adesk, Amigo buenas!!
as @Nick_Boyts says in his answer one thing is to delete the instances of the family in the file and another different is to unload the family of the file for this there is a command called Purge Unused, if you come from autocad sure you are familiar with the purge command works similar, But you can only unload those families that do not have any instances created in the file; I’m not sure but I do not think there is a purge unused node in dynamo, Maybe you should look in the revit API and create a custom node.

Purge Unused is not available in the API, but you can delete the Family elements directly, just like you do the instances.

1 Like