CopyPasteOptions() - Show Revit Popup "Overwrite Family"

Hi, I wish to copy objects from a linked file. The new object uses an updated family. My wish is that Revit asks me if I want to replace it, but currently, I don´t get it to work. Revit copies the object and creates a new family with a number extension in the name. The code I use is the following:

class CustomCopyHandler(IDuplicateTypeNamesHandler):
	def OnDuplicateTypeNamesFound(self, args):
		return DuplicateTypeAction.UseDestinationTypes
		#return DuplicateTypeAction.Abort

options = CopyPasteOptions()
options.SetDuplicateTypeNamesHandler(CustomCopyHandler())


TransactionManager.Instance.EnsureInTransaction(doc)
copy = ElementTransformUtils.CopyElements(linkDoc, eId, doc, tf1, options)
TransactionManager.Instance.TransactionTaskDone()

I need Revit to show this popup:
image

Am I doing something completely wrong?

I updated my code with the “solution” I found, which still does not bring results I was hoping for…

The only destinationtypes seem to be “DuplicateTypeAction.UseDestinationTypes” and “DuplicateTypeAction.Abort”.

“Abort” aborts the whole process and “UseDestinationTypes” creates a new family with an added “1” to the name.

It is my goal to overwrite the old family, but “UseDestinationTypes” does not work like that.
_temp_copy_paste_ref.dyn (26.2 KB)

@Jannis,
look at this: Dismiss a Revit dialog (when Exporting nwc)

Hello @Jannis
try to edit your family from source document with this method and load it to the new document with the method
LoadFamily Method (Document, IFamilyLoadOptions)
then you use the IFamilyLoadOptions Interface

1 Like

Thank you, that did the trick :slight_smile:

1 Like