I have a geometric network set-up with stream lines and water users. I am trying to use ArcPy to automate tracing downstream of each node/junction in my geometric network to get userIDs for all downstream nodes. I can't figure out how to access the selected nodes in the layer group that is output from the tracing. Arcpy.searchcursor("sublayer name")
does not seem to be able to find my sublayer. How can I access just the selected nodes from my tracing?
When I use ListLayers as follows, it doesn't include the trace output layer group with selections even if I can see it in the TOC:
arcpy.TraceGeometricNetwork_management(myNetwork,outNet,mypts,"TRACE_UPSTREAM")
layers = arcpy.mapping.ListLayers(mxd)
for layer in layers:
if layer.isGroupLayer:
if layer.name == arcpy.mapping.Layer(outNet):
for subLayer in layer:
if subLayer.name == userLayer:
#Get a list of downstream user IDs
downstreamUsers = []
rows = arcpy.SearchCursor(userLayer)
for row in rows:
downstreamUsers.append(row.HYDROID)
del rows, row
print "downstream user IDs", downstreamUsers
So I also tried referring specifically to the trace output layer and then the SearchCursor says it can't find my sublayer with the user nodes:
arcpy.TraceGeometricNetwork_management(myNetwork,outNet,mypts,"TRACE_UPSTREAM")
layer = arcpy.mapping.Layer(outNet)
for sublayer in layer:
if subLayer.name == userLayer:
#Get a list of downstream user IDs
downstreamUsers = []
rows = arcpy.SearchCursor(userLayer)
for row in rows:
downstreamUsers.append(row.HYDROID)
del rows, row
print "downstream user IDs", downstreamUsers