ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.NetworkDiagrams Namespace / DiagramElementQueryByElementTypes Class / QueryDiagramContainerElement Property
Example

In This Topic
    QueryDiagramContainerElement Property
    In This Topic
    Indicates whether or not DiagramContainerElements are returned.
    Syntax
    public bool QueryDiagramContainerElement {get; set;}
    Public Property QueryDiagramContainerElement As Boolean
    Example
    Get Diagram Elements
    public void GetDiagramElements(MapView mapView, NetworkDiagram networkDiagram)
    {
      // Create a DiagramElementQueryByExtent to retrieve diagram element junctions whose extent
      // intersects the active map extent
    
      DiagramElementQueryByExtent elementQuery = new DiagramElementQueryByExtent();
      elementQuery.ExtentOfInterest = MapView.Active.Extent;
      elementQuery.AddContents = false;
      elementQuery.QueryDiagramJunctionElement = true;
      elementQuery.QueryDiagramEdgeElement = false;
      elementQuery.QueryDiagramContainerElement = false;
    
      // Use this DiagramElementQueryByExtent as an argument to the QueryDiagramElements method
      DiagramElementQueryResult result = networkDiagram.QueryDiagramElements(elementQuery);
    
      // get the container, junction, edge elements
      //    in this case result.DiagramJunctionElements and result.DiagramEdgeElements will be empty 
      //    since elementQuery.QueryDiagramEdgeElement and elementQuery.QueryDiagramContainerElement are set to false
      IReadOnlyList<DiagramContainerElement> containerElements = result.DiagramContainerElements;
    
      IReadOnlyList<DiagramJunctionElement> junctionElements = result.DiagramJunctionElements;
    
      IReadOnlyList<DiagramEdgeElement> edgeElements = result.DiagramEdgeElements;
    }
    Change the Layout of a Network Diagram
    public void DiagramElementQueryResultAndNetworkDiagramSubsetClasses(Geodatabase geodatabase, DiagramManager diagramManager, string diagramName)
    {
      // Retrieve a diagram
      using (NetworkDiagram diagramTest = diagramManager.GetNetworkDiagram(diagramName))
      {
        // Create a DiagramElementQueryByElementTypes query object to get the diagram elements we want to work with
        DiagramElementQueryByElementTypes query = new DiagramElementQueryByElementTypes();
        query.QueryDiagramJunctionElement = true;
        query.QueryDiagramEdgeElement = true;
        query.QueryDiagramContainerElement = true;
    
        // Retrieve those diagram elements
        DiagramElementQueryResult elements = diagramTest.QueryDiagramElements(query);
    
        // Create a NetworkDiagramSubset object to edit this set of diagram elements
        NetworkDiagramSubset subset = new NetworkDiagramSubset();
        subset.DiagramJunctionElements = elements.DiagramJunctionElements;
        subset.DiagramEdgeElements = elements.DiagramEdgeElements;
        subset.DiagramContainerElements = elements.DiagramContainerElements;
    
        // Edit the shapes of the diagram elements - left as an exercise for the student
        TranslateDiagramElements(subset);
    
        // Save the new layout of the diagram elements
        diagramTest.SaveLayout(subset, true);
      }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also