ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Data.UtilityNetwork Namespace / UtilityNetwork Class
Members Example

In This Topic
    UtilityNetwork Class
    In This Topic
    Represents a utility network.
    Object Model
    UtilityNetwork ClassElement ClassDatastore ClassUtilityNetworkDefinition ClassDiagramManager ClassEnvelope ClassUtilityNetworkState ClassSubnetworkManager ClassTable ClassTable ClassTraceManager ClassTraverseAssociationsResult ClassValidationResult Class
    Syntax
    public sealed class UtilityNetwork : ArcGIS.Core.Data.Dataset, System.IDisposable  
    Public NotInheritable Class UtilityNetwork 
       Inherits ArcGIS.Core.Data.Dataset
       Implements System.IDisposable 
    Remarks
    This class is used to
    • Create and delete associations
    • Update subnetworks
    • Update network topology
    • Get other utility network classes
    Objects of this class are obtained by calling ArcGIS.Core.Data.Geodatabase.OpenDataset<T>
    Example
    Get a Utility Network from a Table
    public static UtilityNetwork GetUtilityNetworkFromTable(Table table)
    {
      UtilityNetwork utilityNetwork = null;
    
      if (table.IsControllerDatasetSupported())
      {
        // Tables can belong to multiple controller datasets, but at most one of them will be a UtilityNetwork
        IReadOnlyList<Dataset> controllerDatasets = table.GetControllerDatasets();
    
        foreach (Dataset controllerDataset in controllerDatasets)
        {
          if (controllerDataset is UtilityNetwork)
          {
            utilityNetwork = controllerDataset as UtilityNetwork;
          }
          else
          {
            controllerDataset.Dispose();
          }
        }
      }
      return utilityNetwork;
    }
    Get a Utility Network from a Layer
    // This routine obtains a utility network from a FeatureLayer, SubtypeGroupLayer, or UtilityNetworkLayer
    public static UtilityNetwork GetUtilityNetworkFromLayer(Layer layer)
    {
      UtilityNetwork utilityNetwork = null;
    
      if (layer is UtilityNetworkLayer)
      {
        UtilityNetworkLayer utilityNetworkLayer = layer as UtilityNetworkLayer;
        utilityNetwork = utilityNetworkLayer.GetUtilityNetwork();
      }
    
      else if (layer is SubtypeGroupLayer)
      {
        CompositeLayer compositeLayer = layer as CompositeLayer;
        utilityNetwork = GetUtilityNetworkFromLayer(compositeLayer.Layers.First());
      }
    
      else if (layer is FeatureLayer)
      {
        FeatureLayer featureLayer = layer as FeatureLayer;
        using (FeatureClass featureClass = featureLayer.GetFeatureClass())
        {
          if (featureClass.IsControllerDatasetSupported())
          {
            IReadOnlyList<Dataset> controllerDatasets = new List<Dataset>();
            controllerDatasets = featureClass.GetControllerDatasets();
            foreach (Dataset controllerDataset in controllerDatasets)
            {
              if (controllerDataset is UtilityNetwork)
              {
                utilityNetwork = controllerDataset as UtilityNetwork;
              }
              else
              {
                controllerDataset.Dispose();
              }
            }
          }
        }
      }
      return utilityNetwork;
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CoreObjectsBase
          ArcGIS.Core.Data.Dataset
             ArcGIS.Core.Data.UtilityNetwork.UtilityNetwork

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also