ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.NetworkDiagrams Namespace / DiagramManager Class / GetDiagramTemplates Method
Example

In This Topic
    GetDiagramTemplates Method
    In This Topic
    Gets the full list of available DiagramTemplates. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetDiagramTemplates() As IReadOnlyList(Of DiagramTemplate)
    public IReadOnlyList<DiagramTemplate> GetDiagramTemplates()

    Return Value

    A list of DiagramTemplates.
    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 Diagram Templates
    {
      // Get all the diagram templates or a template by name
      static void RetrieveDiagramTemplates(UtilityNetwork utilityNetwork)
      {
        string templateName = "ElectricNetworkTemplate";
        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
    {
      // Get all the network diagrams from a template or a diagram by name
      static 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();
    
          // Get a network diagram by name
          NetworkDiagram diagram = template.GetNetworkDiagram(_diagramName);
        }
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also