ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.Topology Namespace / TopologyRule Class
Members Example

In This Topic
    TopologyRule Class
    In This Topic
    Represents a rule that has been defined for a Topology.
    Object Model
    TopologyRule ClassSubtype ClassSubtype Class
    Syntax
    Public NotInheritable Class TopologyRule 
    public sealed class TopologyRule 
    Example
    Get topology rules
    {
      static void GetTopologyRules()
      {
        using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\TestData\GrandTeton.gdb"))))
        using (ArcGIS.Core.Data.Topology.Topology topology = geodatabase.OpenDataset<ArcGIS.Core.Data.Topology.Topology>("Backcountry_Topology"))
        {
          using (TopologyDefinition topologyDefinition = topology.GetDefinition())
          {
            IReadOnlyList<TopologyRule> rules = topologyDefinition.GetRules();
    
            Console.WriteLine($"There are {rules.Count} topology rules defined for the topology:");
            Console.WriteLine("ID \t Origin Class \t Origin Subtype \t Destination Class \t Destination Subtype \t Rule Type");
    
            foreach (TopologyRule rule in rules)
            {
              Console.Write($"{rule.ID}");
              Console.Write(!String.IsNullOrEmpty(rule.OriginClass) ? $"\t{rule.OriginClass}" : "\t\"\"");
              Console.Write(rule.OriginSubtype != null ? $"\t{rule.OriginSubtype.GetName()}" : "\t\"\"");
              Console.Write(!String.IsNullOrEmpty(rule.DestinationClass) ? $"\t{rule.DestinationClass}" : "\t\"\"");
              Console.Write(rule.DestinationSubtype != null ? $"\t{rule.DestinationSubtype.GetName()}" : "\t\"\"");
              Console.Write($"\t{rule.RuleType}");
              Console.WriteLine();
            }
          }
        }
      }
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.Data.Topology.TopologyRule

    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also