ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Layout Class / GetElementsAsFlattenedList Method
Example

In This Topic
    GetElementsAsFlattenedList Method (Layout)
    In This Topic
    Get the collection of Element from the page layout as a flattened list. Nested groups within GroupElement are not preserved.
    Syntax
    public IReadOnlyList<Element> GetElementsAsFlattenedList()
    Public Function GetElementsAsFlattenedList() As IReadOnlyList(Of Element)

    Return Value

    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.0 or higher.
    See Also