I am working on script that iterates through trace flags and traces upstream. For each trace flag, I have selected features from multiple layers in the geometric network that I want to act as barriers to terminate the trace. I have tried merging all of the selected features in each iteration to a single feature class, but if there is not one and only one feature at each junction (we have some points that are disconnected and coincident with connected junctions) then sometimes the disconnected feature is flagged as the barrier and the trace does not end.
I have instead made a list of layers that have selected features as barriers.
list_of_layers =['lyr1','lyr2']
arcpy.TraceGeometricNetwork_management(geomNetwork, r"outNet",traceflag ,"TRACE_UPSTREAM", list_of_layers, "", "", "", "", "NO_TRACE_ENDS", "NO_TRACE_INDETERMINATE_FLOW", "", "", "AS_IS", "", "", "", "AS_IS")
but this fails
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\management.py", line 6253, in TraceGeometricNetwork
raise e
RuntimeError: Object: Error in executing tool
An earlier comment directed me to the tool help with states that this parameter is to be feature layer, not a list of barrier layers
How might one perform an upstream trace with barrier features selected on multiple point layer?
Feature Layer
(not a list of Feature Layers). That said, this "answers" your question as you've proposed it. I'd suggest re-wording your question to "how do I use multiple layers for the trace barrier?"....or something to that affect.