Select to view content in your preferred language

How to add the selected features into the trace locations using python script

453
5
06-07-2023 11:19 PM
kumarprince8071
New Contributor III

I want to add multiple selected features into the trace locations using the arcpy.un.AddTraceLocations() method but i am not able to do that I am using this set of code

result = arcpy.management.SelectLayerByAttribute(
in_layer_or_view="ElectricDevice",
selection_type="NEW_SELECTION",
where_clause="ASSETGROUP = 38",
invert_where_clause=None
)

with
arcpy.da.SearchCursor(result, "*") as cursor:
for row in cursor:
arcpy.un.AddTraceLocations(
in_utility_network=r"D:\UNM\GDB\Naperville_Electric_2213.gdb\UtilityNetwork\Network",
out_feature_class=feature_class_path,
load_selected_features="LOAD_SELECTED_FEATURES",
clear_trace_locations="KEEP_LOCATIONS",
trace_locations=row,
filter_barrier="TRAVERSABILITY_BARRIER"
)
Tags (3)
0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

Does nothing happen or did you get an error? Did your selection work? (try it manually and copy the code snippet)

Select Layer By Attribute (Data Management)—ArcGIS Pro | Documentation

or did it fail at this stage?

Add Trace Locations (Utility Network)—ArcGIS Pro | Documentation 

(eg feature_class_path)

And finally, why use a cursor when you can make the selection and just add the paths from its result?

what is the destination of the result?  gdb? or enterprise?


... sort of retired...
0 Kudos
kumarprince8071
New Contributor III

Yes the Select layer By Attribute is working and also i am getting the selected features .

But after that the Add Trace Locations tool is not adding the features into the feature_class_path.

the destination is gdb.

Not getting any error but the Add Trace Location is not adding the features.

0 Kudos
EddX
by
New Contributor II

did you ever resolve this?

0 Kudos
WonjeaLee
New Contributor

Hey man having the same problem here, Have you solved this?

0 Kudos
PierreloupDucroix
Occasional Contributor II

Hi, I don't think you can add the row from a cursor directly into the trace_location parameter.

It should be formatted as follows :

"'FC name' {featureGlobalID} 'terminal' percentageAlong"

Did you finally succeed ?

0 Kudos