Copy elements from document/link with neverending Duplicate Types window question


I am copying several elements from links or documents to the current project file opened with Dynamo with the nodes of rhythm or springs, but it takes so long because majority of elements contain other elements that Revit indicates they are duplicated and if I want to overwrite with OK button.

is possible to copy all without any question of Duplicate Types?

You would have to use a CopyElements method with CopyPasteOptions so that you can set the SetDuplicateTypeNamesHandler to ignore duplicates.


You’d have to write the code using those methods and members I linked.


Hello @Nick_Boyts

I understand that I would have to define the CopyPasteOptions of the code.

But how is the variable of CopyPasteOptions defined? I tried adding also this code but it seems it needs more definition:

copy = ElementTransformUtils.CopyElements(Document, ICollection(ElementId), Document, Transform, CopyPasteOptions)

options = CopyPasteOptions()

copy = ElementTransformUtils.CopyElements(Document, ICollection(ElementId), Document, Transform, options)

I suggest doing some research on python coding with the Revit API. It can seem like a big step but it’s incredibly powerful once you get comfortable with it.
The argument you have to supply is the object in green, IDuplicateTypeNamesHandler. If you click on it it will explain what it does and give you a link to all its members. You’d have to check the members to see how that value is set. You may even have to do this multiple times if the argument is another method that needs defining.

the implementation of a Net Interface is quite specific in Python
here is a sample example

import clr
import sys
import System
from System.Collections.Generic import List
# all imports and some code
# ...
# ...
# ...
# current_doc = ...
# ...

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

souceDoc = UnwrapElement(IN[0])
myElements = UnwrapElement(IN[1])

copyOptions = CopyPasteOptions()

# start transaction 
myElementIds  = List[ElementId]([x.Id for x in myElements])
newCopyElementIds = ElementTransformUtils.CopyElements(souceDoc, myElementIds, current_doc, None , copyOptions)	
# rest of code 
# ...
# ...