delete duplicate families from revit model

Here’s a quick definition that will delete all duplicate families from a Revit Model based on a Family Type. I considered families to be “duplicate” when I had the exact same Family Type in the exact same Location (you can achieve that by copying a family and then pasting it using command Paste>Aligned to same place). That will usually throw up an error saying that there is multiple instances in the same location and potentially they will get double counted in schedule. Here’s the process:

1. First you need to collect all families that you are checking for duplicates. I used a Family Type selection node to get all of my chairs in the project:


2. Next you need to gather some sort of a unique data about that family to compare and determine if they are indeed duplicates. I used a family location XYZ coordinates for that purpose:





3. Get Element Location is a custom node that can be downloaded from Package Manager. Once you collect the location of each element it comes out as a “revit point” and even though it looks like a string it is not, thus you cannot compare them to each other in Python. I used “To String” node to convert the XYZ Point to a string and then search the list for duplicate “strings”:

4.  Next node is a custom Python node that looks at the whole list of coordinates and lists indices of those that are duplicate. Here’s a code that it uses:

 mylist = IN

i, seen, result = mylist, set(), []
for _index, item in enumerate(i):
    if item not in seen:
        # First time seeing the element
         # Already seen, add the index to the result

#Assign your output to the OUT variable
OUT = result

5. Output of that operation is a list of Index numbers from the input list for all duplicate elements. You can then combine that with a “Get From List” node to extract all of the duplicate families from the original list:



6. Next node is a custom node that simply deletes any element that you feed into it. It will then display a list of elements and their ID’s when it’s done deleting them. Here’s the code for it:

#The input to this node will be stored in the IN variable.
dataEnteringNode = IN

doc = __doc__
result = []

result.append(“Family ID” + IN.Id.ToString() + ” was deleted.”)

#Assign your output to the OUT variable
OUT = reduce(lambda x,y: x.extend(y),result)

Good luck!


*Please note that delete operation can be backed out of by going to active Revit window and simply hitting “Undo” button. However, there is a finite number of undos so be careful when running this script. I would recommend testing it on a detached model first.

Support archi-lab on Patreon!


  1. Jesper Wallaert says:

    I am having a hard time making this work in version 0.7.5
    Is it possible for u to make an update based on version 0.7.5

    • Jasper,

      Yes, It will not be too hard to make it work in newer version of Dynamo. I will have a look at it, but the earliest I think i can find time would be sometime next week. Check back here next week.

  2. Jesper says:

    I am looking forward to seeing what you come up with.

  3. Jesper Wallaert says:

    It says “You do not have permission to preview drafts,, when I hit the link.

Leave a Comment