CopyElements Method (Document, ICollection(ElementId), Document, Transform, CopyPasteOptions)


Copies a set of elements from source document to destination document.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 16.0.0.0 (16.0.0.0)
Since: 2014

Syntax

C#
public static ICollection<ElementId> CopyElements(
	Document sourceDocument,
	ICollection<ElementId> elementsToCopy,
	Document destinationDocument,
	Transform transform,
	CopyPasteOptions options
)
Visual Basic
Public Shared Function CopyElements ( _
	sourceDocument As Document, _
	elementsToCopy As ICollection(Of ElementId), _
	destinationDocument As Document, _
	transform As Transform, _
	options As CopyPasteOptions _
) As ICollection(Of ElementId)
Visual C++
public:
static ICollection<ElementId^>^ CopyElements(
	Document^ sourceDocument, 
	ICollection<ElementId^>^ elementsToCopy, 
	Document^ destinationDocument, 
	Transform^ transform, 
	CopyPasteOptions^ options
)

Parameters

sourceDocument
Type: Autodesk.Revit.DB Document
The document that contains the elements to copy.
elementsToCopy
Type: System.Collections.Generic ICollection ElementId
The set of elements to copy.
destinationDocument
Type: Autodesk.Revit.DB Document
The destination document to paste the elements into.
transform
Type: Autodesk.Revit.DB Transform
The transform for the new elements. Can be a null reference ( Nothing in Visual Basic) if no transform is required.
options
Type: Autodesk.Revit.DB CopyPasteOptions
Optional settings. Can be a null reference ( Nothing in Visual Basic) if default settings should be used.

Return Value

The ids of the newly created copied elements.

Remarks

Copies are placed at their respective original locations or locations specified by the optional transformation.

This method can be used for copying non-view specific elements only. For copying view-specific elements, use the view-specific form of the CopyElements method.

The destination document can be the same as the source document.

This method performs rehosting of elements where applicable.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException The given element id set is empty. -or- One or more elements in elementsToCopy do not exist in the document. -or- Some of the elements cannot be copied, because they are view-specific.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL
Autodesk.Revit.Exceptions InvalidOperationException The elements cannot be copied.
Autodesk.Revit.Exceptions OperationCanceledException User cancelled the operation.

See Also