ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.NetworkDiagrams Namespace / DiagramManager Class / GetNetworkDiagrams Method / GetNetworkDiagrams(Envelope,IEnumerable<Guid>) Method
The extent ArcGIS.Core.Geometry.Envelope of interest where to search for overlapping network diagrams.
An enumerable containing the global IDs of the input features.
Example

In This Topic
    GetNetworkDiagrams(Envelope,IEnumerable<Guid>) Method
    In This Topic
    Gets the list of NetworkDiagrams which either overlap the specified extent or contain at least one of the specified features. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    extentOfInterest
    The extent ArcGIS.Core.Geometry.Envelope of interest where to search for overlapping network diagrams.
    globalIDs
    An enumerable containing the global IDs of the input features.

    Return Value

    A list of NetworkDiagrams.
    Exceptions
    ExceptionDescription
    A geodatabase-related exception has occurred. For example, the diagram manager is invalid.
    This method or property must be called within the lambda passed to QueuedTask.Run
    Example
    Get Network Diagrams
    {
      static void GetDiagram(UtilityNetwork utilityNetwork, IEnumerable<Guid> globalIDs)
      {
        Envelope extentOfInterest = MapView.Active.Map.GetDefaultExtent();
    
        using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
        {
          // Get all the diagrams
          IReadOnlyList<NetworkDiagram> diagrams = diagramManager.GetNetworkDiagrams();
    
          // Get a diagram by name
          NetworkDiagram diagram = diagramManager.GetNetworkDiagram(_diagramName);
    
          // Get diagrams by extent
          diagrams = diagramManager.GetNetworkDiagrams(extentOfInterest);
    
          // Get diagrams from a set of utility network feature GlobalIDs
          diagrams = diagramManager.GetNetworkDiagrams(globalIDs);
    
          // Get diagrams from a set of utility network feature GlobalIDs within an extent
          diagrams = diagramManager.GetNetworkDiagrams(extentOfInterest, globalIDs);
        }
      }
    }
    Get a list of Network Diagrams with inconsistent ConsistencyState
    {
      static List<NetworkDiagram> GetInconsistentDiagrams(UtilityNetwork utilityNetwork)
      {
        // Get the DiagramManager from the utility network
        using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
        {
          List<NetworkDiagram> networkDiagrams = new List<NetworkDiagram>();
    
          // Loop through the network diagrams in the diagram manager
          foreach (NetworkDiagram diagram in diagramManager.GetNetworkDiagrams())
          {
            NetworkDiagramInfo diagramInfo = diagram.GetDiagramInfo();
    
            // If the diagram is not a system diagram and is in an inconsistent state, add it to our list
            if (!diagramInfo.IsSystem &&
                diagram.GetConsistencyState() != NetworkDiagramConsistencyState.DiagramIsConsistent)
            {
              networkDiagrams.Add(diagram);
            }
            else
            {
              diagram.Dispose(); // If we are not returning it we need to Dispose it
            }
          }
    
          return networkDiagrams;
        }
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also