CopyPasteOption ().SetDuplicateTypeNamesHandler( IDuplicateTypeNamesHandler handler)

Hi All,

Does anyone know how to convert the following code to Python (from the sample SDK)?

CopyPasteOptions options = new CopyPasteOptions();
options.SetDuplicateTypeNamesHandler(new HideAndAcceptDuplicateTypeNamesHandler());


class HideAndAcceptDuplicateTypeNamesHandler : IDuplicateTypeNamesHandler
{

	public DuplicateTypeAction OnDuplicateTypeNamesFound(DuplicateTypeNamesHandlerArgs args)
        {
          return DuplicateTypeAction.UseDestinationTypes;
        }
}

image

image

import clr
clr.AddReference('RevitApi')
from Autodesk.Revit.DB import DuplicateTypeAction

dta = DuplicateTypeAction.UseDestinationTypes
OUT = dta

This should be sufficient though:

DuplicateTypeAction.UseDestinationTypes
1 Like

Hi, could you please post your result?
I don´t get it to work. I want to replace families if the same name already exists. Currently it copies the object and adds a new family with the same name ending with a consecutive number.

options = CopyPasteOptions()
options.SetDuplicateTypeNamesHandler()

# I struggle with this area
#options.SetDuplicateTypeNamesHandler(new DuplicateTypeAction.UseDestinationTypes) 
#DuplicateTypeAction.UseDestinationTypes
#new IDuplicateTypeNamesHandler

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