How to add rule and add feature class to topology using arcpy

المشرف العام

Administrator
طاقم الإدارة
This script successfully added feature classes to topology when that is all I had scripted it to do. Now I've added the add rule parts (#added) and it's still just adding feature classes without adding rules. Any suggestions? Thank you.

import arcpyimport os# Set the workspacearcpy.env.workspace = "D:\topology\Contours.gdb"# The name of the data_set containing the topologydata_set = "Contours"# The name of the topologytopology = "contour_topology"# Rules for topologytopoRules = ["Must Not Self-Overlap (Line)", "Must Not Self-Intersect (Line)"]# Get the fully qualified name/path of the topologypath_topology = os.path.join(arcpy.env.workspace, data_set, topology)# Get the feature classes within the specified datasetfeature_classes = arcpy.ListFeatureClasses(feature_dataset = data_set)# Check to make sure there are some feature classesif feature_classes is not None: # for each feature class for fc in feature_classes: # Get the fully qualified path to the feature class path_fc = os.path.join(arcpy.env.workspace, data_set, fc) print(path_fc) print(fc) # Try and add the feature class to the topology try: # add the feature class to the topology arcpy.AddFeatureClassToTopology_management(path_topology, path_fc, 1, 1) # added the rules here arcpy.AddRuleToTopology_management(path_topology, topoRules[0], path_fc," ", " ", " ") arcpy.AddRuleToTopology_management(path_topology, topoRules[1], path_fc," ", " ", " ") except Exception as e: # print any errors we might get print(e)

أكثر...
 
أعلى