Select to view content in your preferred language

How to get a selection via arcpy.un.trace - Utility Network Model

505
0
09-07-2023 10:31 PM
EdX1
by
Occasional Contributor

Hello, I wish to get a selection output from a trace, so I can then feed that selection into an arcpy.SelectLayerByAttribute_management process. My current code is:

 

 

 

traceResults = arcpy.un.Trace(
"<URL HERE>", # URL of the feature service (un service)
"SUBNETWORK", # Trace type, in this case, it's 
None, # Starting points (usually a feature class or layer), set to None in this case
None, # Barriers (usually a feature class or layer), set to None in this case
"Water", # Network name
"Pressure", # Utility category
'', # Function barriers (set to an empty string)
"{}".format(PressureZone), # Subnetwork name based on the PressureZone variable
'', # Trace condition barriers (set to an empty string)
"INCLUDE_CONTAINERS", # Include containers in the trace
"INCLUDE_CONTENT", # Include content in the trace
"INCLUDE_STRUCTURES", # Include structures in the trace
"INCLUDE_BARRIERS", # Include barriers in the trace
"VALIDATE_CONSISTENCY", # Validate consistency
"'P:Device Status' IS_EQUAL_TO SPECIFIC_VALUE 0 OR;'P:Device Status' IS_EQUAL_TO SPECIFIC_VALUE 2 OR;'Lifecycle Status' DOES_NOT_INCLUDE_ANY SPECIFIC_VALUE 24 OR;Category IS_EQUAL_TO SPECIFIC_VALUE 'CP Only' #", # Trace condition
None, # function_barriers
"BOTH_JUNCTIONS_AND_EDGES", # Type of features to trace
None, # filter_barriers
None, # Barriers by object ID, filter_function_barriers
"BOTH_JUNCTIONS_AND_EDGES", # Type of features to trace (again)
'', # filter_scope
"DO_NOT_FILTER", # Filter type
None, # nearest_count
'', # nearest_cost_network_attribute????
None, # Starting points class names
None, # Starting points by object ID
None, #
None, #
"WaterLine/Potable Network/WaterMain", 
None, #
"EXCLUDE_ISOLATED_FEATURES", # Exclude isolated features
"DO_NOT_IGNORE_BARRIERS_AT_STARTING_POINTS", # Do not ignore barriers at starting points
"DO_NOT_INCLUDE_UP_TO_FIRST_SPATIAL_CONTAINER", # Do not include up to first spatial container
"ELEMENTS", # Trace result type
"NEW_SELECTION", # Selection type
"CLEAR_ALL_PREVIOUS_TRACE_RESULTS",
'', # Result file name
"Trace_Results_Aggregated_Points",
"Trace_Results_Aggregated_Lines",
"Trace_Results_Aggregated_Polygons",
"TRACE_INDETERMINATE_FLOW",
"DO_NOT_VALIDATE_LOCATABILITY",
"DO_NOT_USE_TRACE_CONFIGURATION",
'', # Extent
jsonPath, # JSON configuration path
)

 

 

As you can see I currently have the output type set as "ELEMENTS" rather than SELECTION, and I am outputting the data to a json file which I am them getting GIDs from and feeding into a selection.

The reason I am using elements is that I can't seem to get SELECTION to work. When I run the code as is, it works fine and outputs the selected elements. If I change ELEMENTS to SELECTION I get return result of '/', which obviously does not work in arcpy.SelectLayerByAttribute_management.

Does anyone know what I am doing wrong?

Tags (1)
0 Kudos
0 Replies