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


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

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(
	View sourceView,
	ICollection<ElementId> elementsToCopy,
	View destinationView,
	Transform additionalTransform,
	CopyPasteOptions options
)
Visual Basic
Public Shared Function CopyElements ( _
	sourceView As View, _
	elementsToCopy As ICollection(Of ElementId), _
	destinationView As View, _
	additionalTransform As Transform, _
	options As CopyPasteOptions _
) As ICollection(Of ElementId)
Visual C++
public:
static ICollection<ElementId^>^ CopyElements(
	View^ sourceView, 
	ICollection<ElementId^>^ elementsToCopy, 
	View^ destinationView, 
	Transform^ additionalTransform, 
	CopyPasteOptions^ options
)

Parameters

sourceView
Type: Autodesk.Revit.DB View
The view in the source document that contains the elements to copy.
elementsToCopy
Type: System.Collections.Generic ICollection ElementId
The set of elements to copy.
destinationView
Type: Autodesk.Revit.DB View
The view in the destination document that the elements will be pasted into.
additionalTransform
Type: Autodesk.Revit.DB Transform
The transform for the new elements, in addition to the transformation between the source and destination views. Can be a null reference ( Nothing in Visual Basic) if no transform is required. The transformation must be within the plane of the destination view.
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

This method can be used for both view-specific and model elements.

Both source and destination views must be 2D graphics views capable of drawing details and view-specific elements (floor and ceiling plans, elevations, sections, drafting views.) Drafting views cannot be used as a destination for model elements.

The pasted elements are repositioned to ensure proper placement in the destination view (e.g. elevation is changed when copying from a level to a different level.) Additional transformation within the destination view can be performed by providing additionalTransform argument. This additional transformation must be within the plane of the destination view.

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

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

All view-specific elements in the set must be specific to the source view. Elements specific to views other than the source view or to multiple views cannot be copied.

This method performs rehosting of elements where applicable.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException The given element id set is empty. -or- The specified view cannot be used as a source or destination for copying elements between two views. -or- Some of the elements cannot be copied, because they belong to a different document. -or- Some of the elements cannot be copied, because they belong to a different view. -or- The elements cannot be copied into the destination view. Drafting views cannot contain model elements. -or- The transformation is not within the plane of the destination view.
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