ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.NetworkDiagrams Namespace / DiagramManager Class
Members Example

In This Topic
    DiagramManager Class
    In This Topic
    Represents a diagram manager object, the core class in the network diagram API.
    Object Model
    DiagramManager ClassNetworkDiagram ClassDiagramTemplate ClassNetworkDiagram Class
    Syntax
    public sealed class DiagramManager : ArcGIS.Core.CoreObjectsBase, System.IDisposable  
    Public NotInheritable Class DiagramManager 
       Inherits ArcGIS.Core.CoreObjectsBase
       Implements System.IDisposable 
    Remarks
    The DiagramManager object is obtained by calling ArcGIS.Core.Data.UtilityNetwork.UtilityNetwork.GetDiagramManager. Use the DiagramManager class to:
    • Create network diagrams
    • Retrieve diagram templates
    • Retrieve network diagrams
    Example
    Get the Diagram Manager
    using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
    {
      // Todo - do something
    }
    Get Network Diagrams
    using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
    {
      // get all the diagrams
      IReadOnlyList<NetworkDiagram> diagrams = diagramManager.GetNetworkDiagrams();
    
      // get a diagram by name
      NetworkDiagram diagram = diagramManager.GetNetworkDiagram(diagrameName);
    
      // 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
    public List<NetworkDiagram> GetInconsistentDiagrams(UtilityNetwork utilityNetwork)
    {
      // Get the DiagramManager from the utility network
    
      using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
      {
        List<NetworkDiagram> myList = 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)
          {
            myList.Add(diagram);
          }
          else
          {
            diagram.Dispose(); // If we are not returning it we need to Dispose it
          }
        }
    
        return myList;
      }
    }
    Get Diagram Templates
    public void RetrieveDiagramTemplates(UtilityNetwork utilityNetwork)
    {
      using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
      {
        // get all templates
        IReadOnlyList<DiagramTemplate> templates = diagramManager.GetDiagramTemplates();
    
        // get a template by name
        DiagramTemplate template = diagramManager.GetDiagramTemplate(templateName);
      }
    }
    Get Network Diagrams from a Diagram Template
    public void GetNetworkDiagramFromDiagramTemplates(UtilityNetwork utilityNetwork)
    {
      using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
      {
        // get the first templates
        DiagramTemplate template = diagramManager.GetDiagramTemplates().FirstOrDefault();
    
        // get the network diagrams fromt he template
        IEnumerable<NetworkDiagram> diagrams = template.GetNetworkDiagrams();
    
        // or get a network diagram by name
        NetworkDiagram diagram = template.GetNetworkDiagram(diagrameName);
      }
    }
    Create a Network Diagram
    public void CreateNetworkDiagram(UtilityNetwork utilityNetwork, IEnumerable<Guid> globalIDs)
    {
      using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
      {
        // get the template
        DiagramTemplate template = diagramManager.GetDiagramTemplate(templateName);
    
        // create the diagram
        NetworkDiagram diagram = diagramManager.CreateNetworkDiagram(template, globalIDs);
      }
    }
    Get Network Diagram Information as JSON string
    public void GetDiagramContent(UtilityNetwork utilityNetwork)
    {
      using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
      {
        // get a diagram by name
        NetworkDiagram diagram = diagramManager.GetNetworkDiagram(templateName);
    
        string json_content = diagram.GetContent(true, true, true, true);
      }
    }
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CoreObjectsBase
          ArcGIS.Core.Data.NetworkDiagrams.DiagramManager

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also