Hi UN experts,
I have a need for a trace tool in ArcGIS Pro that updates certain attributes for the features traced. The tool also needs to provide option to the user to choose the trace direction at the start location. I am trying to use barriers to stop the trace going into unwanted directions to force it go only in the selected direction.
I tried to add records to arcpy.env.scratchWorkspace\\UN_Temp_Barriers using
arcpy.un.AddTraceLocations(self.un_layer, self.trace_barrier_fc,
"DO_NOT_LOAD_SELECTED_FEATURES", "KEEP_LOCATIONS",
"{} {} # 0.5".format(layer_name, layer_guid),
"FILTER_BARRIER")
However, I get the error below:
ERROR 000725: Output Feature Class: Dataset <location>\\UN_Temp_Barriers already exists.
Failed to execute (AddTraceLocations)
I could reproduce this problem. When I run the tool interactively in ArcGIS Pro using Add Trace Locations tool, it worked as below.
But then when I copied the Python command for the above successful run in the Python window, it gave same error.
So I added,
arcpy.env.overwriteOutput = True
and if fixed the problem for AddTraceLocations. But when I run my tool, after the successful run, it just drops the arcpy.env.scratchWorkspace\\UN_Temp_Barriers table afterwards. Any one knows how I can persist UN_Temp_Barriers table? any arcpy.env value that I need to set?
Cheers,
Solved! Go to Solution.
The scratch workspace is a great idea, since you can re-use the same table within the same session instead of having to recreate it every time your run your tool. If you did want to create a new temp layer each time you ran your tool, I'd recommend you use the memory workspace for the duration of the trace. To do this just use the word "memory" for the workspace path (e.g. "memory\\temp_start_barriers").