The following code works as expected in an ArcGIS Notebook (2.9.x):
# variables
arcpy.env.workspace = r"\\foo\Staging\NG911.gdb\ESINET"
staging = r"\\foo\Staging\NG911.gdb\ESINET"
ng_pb = os.path.join(staging, "NG911_PB")
topology = os.path.join(staging, "ESI_topology")
fcs = arcpy.ListFeatureClasses()
# create topology
arcpy.management.CreateTopology(staging, "ESI_topology")
print('topology created')
for fc in fcs:
arcpy.management.AddFeatureClassToTopology(topology, fc, 1,1)
print(arcpy.GetMessages())
# rules for polygon layers
topoRules = ["Must Be Covered By Feature Class Of (Area-Area)", "Must Be Properly Inside
(Point-Area)", "Must Be Inside (Line-Area)"]
boundaries = fcs[0:3]
sitepts = fcs[4]
centerline = fcs[5]
# add rules
for fc in boundaries:
arcpy.management.AddRuleToTopology(topology, topoRules[0], fc, '', ng_pb, '')
arcpy.management.AddRuleToTopology(topology, topoRules[0], ng_pb, '', fc, '')
print(arcpy.GetMessages())
But when I run it as a standalone script in Python 3.7.x shell I get the following error:
Traceback (most recent call last):
File "C:\ESINET\Python\esinet_2.py", line 96, in <module>
arcpy.management.AddRuleToTopology(topology, topoRules[0], fc, '', ng_pb, '')
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 22746, in AddRuleToTopology
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 22743, in AddRuleToTopology
retval = convertArcObjectToPythonObject(gp.AddRuleToTopology_management(*gp_fixargs((in_topology, rule_type, in_featureclass, subtype, in_featureclass2, subtype2), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
The table was not found. [ESI_topology]
The table was not found. [ESI_topology]
Failed to execute (AddRuleToTopology).
I've tried a few different ways of declaring the ESI_topology table (full path rather than using os.join, plain text rather than a variable since my workspace is set to the Feature Dataset) but I'm really at a loss for why this isn't working outside of ArcGIS Pro. Error 999999 of course isn't helpful at all, so I'm hoping someone will recognize something out of place.
fcs
in the code you show?fcs
to check if featureclasses in boundaries, sitepts & centerline are in the order you think they are? Maybe arcpy.ListFeatureClasses() returns a list in a different order depending on how its being run?