ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GraphicsLayerExtensions Class / CopyElements Method / CopyElements(GraphicsLayer,IEnumerable<Element>) Method
The elements to be copied
Example

In This Topic
    CopyElements(GraphicsLayer,IEnumerable<Element>) Method
    In This Topic
    Copy the elements into the graphics layer. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    graphicsLayer
    elements
    The elements to be copied

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    elements must belong to a graphics layer
    Map has reached maximum graphics count limit of 4000 elements. One or more elements cannot be created.
    Map has reached maximum graphics size limit of 10 MB. One or more elements cannot be created.
    Remarks
    Only elements from a single graphics layer can be copied at one time. To copy elements from multiple graphics layers CopyElements must be called each time.
    If a group element is provided in the list of elements to be copied then the group element and all its children will be copied.
    If a child of a group element is provided in the list in addition to its parent then the parent takes precedence (i.e. the entire group element is copied and not just that child).
    If a child element of a group element is provided in the list but its parent is not then only the child element is copied. The parent of the copied element will be the target graphics layer.
    The map view displaying the graphics layers should be initialized.
    Example
    Copy Graphic elements
    //on the QueuedTask
    var elems = sourceGraphicsLayer.FindElements(new List<string>() { "Point 1", "Line 3", "Text 1" });
    var copiedElements = targetGraphicsLayer.CopyElements(elems);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also