Retrieve duplicate family instances and delete them

Dear All,
I am placing a large amount of families with a python script in revit. The issue is, that everytime i run the script, another instance is placed, which leads to a duplication. Is there a python script, which could help me asking the following question:
-are there any duplicate instances in my list based on the location of the insertion point?
-if yes, delete these items/ remove indices of these items

I know there is a clockwork method online, but I prefer to stick to python and the revit api for the sake of code stability.
Thanks in advance:

Keep in mind that this means you will have to update and maintain this code by yourself for every use. Packages exist because they make that type of maintenance easier. Fixing that line of python code that changed with an API update isn’t bad if it’s in 1 spot. If it’s in 10 spots and you don’t have a record of which python scripts used that call… well suddenly you have a bigger issue.

For the code you’re after, I believe that the nodes actually call the Revit API as you would if you were using python coded from scratch, and that you could likely reverse engineer them for your use. Post your code as preformatted text and someone may be able to help you to better incorporate this.

1 Like