I have a utility network model, I need to create a startpoint on a subnetwork controller. I wish to use arcpy.un.AddTraceLocations to add a start point with the required fields (i.e. GID, TERMINALID) for a trace.
Currently I have this, which runs (see code block below), but does not output any data into the generated feature class at "D:\cons\UNM.sde\StartingPoints", it creates the headers, but there is no actual data rows. In the documentation: ( https://pro.arcgis.com/en/pro-app/latest/tool-reference/utility-networks/add-trace-locations.htm ) specifically this part:
implies I can use LOAD_SELECTED_FEATURES to populate the new starting points feature class with selected features. How do I go about selecting this from the utility network model input inside my python script? How can I load in the required data format and how would I make a selection on that data? I wish to select one device.
I have tried replacing the input utility network model (first parameter) with a selection of a point from my UNM, which is created via arcpy.MakeFeatureLayer_management, then arcpy.SelectLayerByAttribute_management, but my starting points feature class remains empty.
My code:
arcpy.un.AddTraceLocations(r"https://gishub.test/server/rest/services/UNM/Utility_Network_Model/FeatureServer/0", r"D:\cons\UNM.sde\StartingPoints", "LOAD_SELECTED_FEATURES", "CLEAR_LOCATIONS")
Why are you using LOAD_SELECTED_FEATURES when you can just pass the trace locations through the trace_locations parameter? Seems like extra work to generate a selection instead of just passing features to the tool.
I also think that for selections to work you need to be accessing a feature layer as the map/layer object holds selection state. If you're working directly with a data source, you'll need to pass through features directly instead of loading a selection from a view that it doesn't exist in.