ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Layout Class / GetElements Method
Example

In This Topic
    GetElements Method (Layout)
    In This Topic
    Get the collection of elements from the page layout. Nesting within GroupElementis preserved.
    Syntax
    public IReadOnlyList<Element> GetElements()
    Public Function GetElements() As IReadOnlyList(Of Element)

    Return Value

    Remarks
    Use GetElementsAsFlattenedList to flatten the collection otherwise enumerate any returned GroupElement individually.
    Elements are returned in Z order. The 0th Element is at the back or 'bottom' and the 'Nth' element is at the front or 'top'.
    Example
    Find layout elements
    //on the QueuedTask
    //Find elements by name
    var layoutElementsToFind = layout.FindElements(new List<string>() { "Point 1", "Line 3", "Text 1" });
    //Get the collection of elements from the page layout. Nesting within GroupElement is preserved.
    var elementCollection = layout.GetElements();
    //Get the collection of Element from the page layout as a flattened list. Nested groups within GroupElement are not preserved.
    var elements = layout.GetElementsAsFlattenedList();
    //Convert collection of the elements to a collection of GraphicElements.
    var graphicElements = elements.ToList().ConvertAll(x => (GraphicElement)x);
    //Find elements by type
    //Find all point graphics in the Layout
    var pointGraphics = graphicElements.Where(elem => elem.GetGraphic() is CIMPointGraphic);
    //Find all line graphics in the Graphics Layer
    var lineGraphics = graphicElements.Where(elem => elem.GetGraphic() is CIMLineGraphic);
    ////Find all polygon graphics in the Graphics Layer
    var polyGraphics = graphicElements.Where(elem => elem.GetGraphic() is CIMPolygonGraphic);
    ////Find all text graphics in the Graphics Layer
    var textGraphics = graphicElements.Where(elem => elem.GetGraphic() is CIMTextGraphic);
    ////Find all picture graphics in the Graphics Layer
    var pictureGraphic = graphicElements.Where(elem => elem.GetGraphic() is CIMPictureGraphic);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also