<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to parse NETWORK_LAYERS results in Python? in Trace Network Questions</title>
    <link>https://community.esri.com/t5/trace-network-questions/how-to-parse-network-layers-results-in-python/m-p/1362414#M145</link>
    <description>&lt;P&gt;I'm encountering the same issue.&amp;nbsp; I'm expecting the trace to return a Group Layer object that could then be manipulated in the same way that the old Geometric Network trace results could be processed.&amp;nbsp; It appears the new trace only returns a string when the result type = 'NETWORK_LAYERS'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;trace_result = arcpy.tn.Trace(network, 'CONNECTED', start_points, lyr_valve, include_barriers='INCLUDE_BARRIERS', validate_consistency='VALIDATE_CONSISTENCY', result_types='NETWORK_LAYERS', out_network_layer='TRACE1')

print(trace_result)

&amp;gt; Trace_Results_Aggregated_Points&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's frustrating because the script works as intended within ArcGIS Pro but doesn't as a stand-alone.&amp;nbsp; I suspect that the Network Layer result type is only valid within ArcGIS Pro.&amp;nbsp; The wording in the documentation should be made more clear if this is the case.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dan_Joyce_OE_0-1702970343645.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/89443iB01C0C1D01C88CB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dan_Joyce_OE_0-1702970343645.png" alt="Dan_Joyce_OE_0-1702970343645.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;At the moment, this isn't a useful option for me as the stand-alone script gets published as a GP service so that it can be called from a web app.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Dec 2023 07:37:57 GMT</pubDate>
    <dc:creator>Dan_Joyce_OE</dc:creator>
    <dc:date>2023-12-19T07:37:57Z</dc:date>
    <item>
      <title>How to parse NETWORK_LAYERS results in Python?</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-parse-network-layers-results-in-python/m-p/1355036#M141</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I would like to use Trace with &lt;/SPAN&gt;result_types=['NETWORK_LAYERS']&lt;SPAN&gt;. I am unable to drill the layers in &lt;/SPAN&gt;out_network_layer&lt;SPAN&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;Here is an example of an attempt:&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;out_netk_layer = "out_net_lay"
stream_layer_name = 'Stream'
res = arcpy.tn.Trace(in_trace_network=t_network,
			trace_type="SHORTEST_PATH",
			starting_points=starting_points,
			shortest_path_network_attribute_name="Shape length",
			validate_consistency="VALIDATE_CONSISTENCY",
			result_types=['NETWORK_LAYERS'],
			out_network_layer=out_netk_layer)
	
if res:
	total_length = 0
	feature_class_path = '{}\\{}'.format(out_netk_layer, stream_layer_name)
    with arcpy.da.SearchCursor(feature_class_path, ["SHAPE@"]) as cursor:
        for row in cursor:
            shape = row[0]
            if shape.isSelected:
				total_length += shape.length
	arcpy.AddMessage("Total length : {} meters".format(total_length))
else:
	arcpy.AddWarning("no trace result")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcgisscripting.ExecuteError: Execution failed. The parameters are &lt;/SPAN&gt;&lt;SPAN class=""&gt;not&lt;/SPAN&gt;&lt;SPAN&gt; valid. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ERROR 000732: Input Entities: Dataset out_net_lay/stream does &lt;/SPAN&gt;&lt;SPAN class=""&gt;not&lt;/SPAN&gt;&lt;SPAN&gt; exist &lt;/SPAN&gt;&lt;SPAN class=""&gt;or&lt;/SPAN&gt; &lt;SPAN class=""&gt;is&lt;/SPAN&gt; &lt;SPAN class=""&gt;not&lt;/SPAN&gt;&lt;SPAN&gt; supported&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where can I find a code example? What anomaly do you see here? Thanks for everything&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 09:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-parse-network-layers-results-in-python/m-p/1355036#M141</guid>
      <dc:creator>LaurieMhu</dc:creator>
      <dc:date>2023-11-30T09:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse NETWORK_LAYERS results in Python?</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-parse-network-layers-results-in-python/m-p/1362414#M145</link>
      <description>&lt;P&gt;I'm encountering the same issue.&amp;nbsp; I'm expecting the trace to return a Group Layer object that could then be manipulated in the same way that the old Geometric Network trace results could be processed.&amp;nbsp; It appears the new trace only returns a string when the result type = 'NETWORK_LAYERS'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;trace_result = arcpy.tn.Trace(network, 'CONNECTED', start_points, lyr_valve, include_barriers='INCLUDE_BARRIERS', validate_consistency='VALIDATE_CONSISTENCY', result_types='NETWORK_LAYERS', out_network_layer='TRACE1')

print(trace_result)

&amp;gt; Trace_Results_Aggregated_Points&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's frustrating because the script works as intended within ArcGIS Pro but doesn't as a stand-alone.&amp;nbsp; I suspect that the Network Layer result type is only valid within ArcGIS Pro.&amp;nbsp; The wording in the documentation should be made more clear if this is the case.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dan_Joyce_OE_0-1702970343645.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/89443iB01C0C1D01C88CB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dan_Joyce_OE_0-1702970343645.png" alt="Dan_Joyce_OE_0-1702970343645.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;At the moment, this isn't a useful option for me as the stand-alone script gets published as a GP service so that it can be called from a web app.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 07:37:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-parse-network-layers-results-in-python/m-p/1362414#M145</guid>
      <dc:creator>Dan_Joyce_OE</dc:creator>
      <dc:date>2023-12-19T07:37:57Z</dc:date>
    </item>
  </channel>
</rss>

