<?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 iterate traces and feature selections in Trace Network Questions</title>
    <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1108928#M85</link>
    <description>&lt;P&gt;Hi Tim,&lt;/P&gt;&lt;P&gt;I use ArcGIS Pro 2.7.2. In ArcGIS Pro Trace geoprocessing tool works as expected and selects some network elements. I have copied Python script and placed it in my application, but I don't know how to get selection from it.&amp;nbsp;I have checked all results of&amp;nbsp;arcpy.tn.Trace and my selection must be in element number 2.&amp;nbsp; My python script:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    result = arcpy.tn.Trace(traceNetworkDataset, "UPSTREAM", startPointsFC, None, "NO_DIRECTION", '', "EXCLUDE_BARRIERS",
                            "DO_NOT_VALIDATE_CONSISTENCY", "DO_NOT_IGNORE_BARRIERS_AT_STARTING_POINTS", "IGNORE_INDETERMINATE_FLOW",
                            None, None, "BOTH_JUNCTIONS_AND_EDGES", None, None, "SELECTION", "NEW_SELECTION", "CLEAR_ALL_PREVIOUS_TRACE_RESULTS", '',
                            "Trace_Results_Aggregated_Points", "Trace_Results_Aggregated_Lines", None, "DO_NOT_USE_TRACE_CONFIGURATION", '')&lt;/LI-CODE&gt;&lt;P&gt;Your scripts don't use selection but maybe you know how to get it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Oct 2021 17:27:48 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2021-10-19T17:27:48Z</dc:date>
    <item>
      <title>How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35983#M1</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a GP model that performs a trace and then assigns a long integer stored in the HydroID variable to a field in the edge layer.&amp;nbsp; Calculate Field has the Updated Trace Network as a precondition, so it waits until the trace is finished and there is a selection.&amp;nbsp; This works fine when I run the model.&amp;nbsp; The model is shown below, and is named "_Single Junction To Edges".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="GP model to trace and assign values to results" class="jive-emoji image-1 jive-image j-img-original" src="/legacyfs/online/512612_ID to edges.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem arises when I encapsulate this model in another model with an iterator.&amp;nbsp; I want to iterate through a selected set of junctions, and for each one, perform the trace and calculate the field.&amp;nbsp; However, calculate field appears to be running on the entire edge layer rather than the selection.&amp;nbsp; As the model runs, I can see the selections being made in the map, but the tool ignores them.&amp;nbsp; The model with the iterator, which includes "_Single Junction To Edges" as one of the tools, is shown below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Iterator GP model" class="jive-emoji jive-image image-2 j-img-original" src="/legacyfs/online/512613_IDs to edges iterator.png" /&gt;&lt;/P&gt;&lt;P&gt;What do I need to do to get the iterator version to work like the standalone version with respect to using feature selections when it comes time to calculate the field?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do acknowledge that outputting a group layer with the selection from the Trace tool in Pro 2.7, as discussed in this &lt;A _jive_internal="true" href="https://community.esri.com/thread/261946-how-do-you-work-with-trace-results"&gt;thread on working with trace results&lt;/A&gt;, may be the solution.&amp;nbsp; But it seems like the single model was working correctly, so I wonder if I'm just missing something that will make it work in the iterator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm on Pro 2.6.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2020 20:27:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35983#M1</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2020-11-05T20:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35984#M2</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the output destination set to in _SingleJunctionoEdges in the iterated tool?&amp;nbsp; Have you used inline variable substitution?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not, I would guess your output is just being overwritten each time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or script that bad boy...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2020 21:17:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35984#M2</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-11-05T21:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35985#M3</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think there is an output destination in _SingleJunctionoEdges.&amp;nbsp; The input to that tool is a layer, and the tool calculates a field on the layer, so the output labeled Output Feature Class is actually the input layer.&amp;nbsp; Or maybe I'm misunderstanding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I put the geodatabase and toolbox here in case you want to have a look:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://utexas.box.com/s/5ogm520r27axbe8w0oo3p7ilhkqxd48u" title="https://utexas.box.com/s/5ogm520r27axbe8w0oo3p7ilhkqxd48u"&gt;NetworkTest.zip - Box&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To test:&lt;/P&gt;&lt;P&gt;1. Add the Hydro network in the geodatabase to a map.&lt;/P&gt;&lt;P&gt;2. Select a single WRProxyMZ point (or more, but it just takes longer).&lt;/P&gt;&lt;P&gt;3. In the toolbox, run Junctions To Edges Iterator, with the Hydro network, WRProxyMZ, and NHDFlowline as inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The tool's job is to trace upstream from each selected point, using all other WRProxyMZ points as barriers.&amp;nbsp; For each upstream edge found between the starting point and the upstream points, assign the JunctionID attribute of the edges to be equal to the HydroID of the starting point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The freshly unzipped geodatabase has all JunctionIDs as -1.&amp;nbsp; When the tool finishes, the edges in the trace results for the final iteration are selected in the map.&amp;nbsp; However, the calculate field task ran on the entire layer and not just the selection, as evidenced by all NHDFlowlines having the same JunctionID, e.g., 1392.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2020 15:25:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35985#M3</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2020-11-06T15:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35986#M4</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I attempted the same task in a script tool and found the same result: The input edge layer does not have the trace results as a selection when arcpy.tn.Trace completes.&amp;nbsp; I'm thinking the only recourse until 2.7 is released, is to output an aggregated feature and then use a spatial filter to select the appropriate edges, which will be very slow.&amp;nbsp; I'm also worried about geometries not matching exactly since &lt;A _jive_internal="true" href="https://community.esri.com/thread/262432-trace-from-ribbon-vs-from-exported-feature-class" target="_blank"&gt;exported junctions don't seem to return the same results as an interactive starting point&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy


arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;

network &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
junction_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
edge_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;


&lt;SPAN class="comment token"&gt;# Trace network overwrites selections, so grab HydroIDs before tracing&lt;/SPAN&gt;
hydro_ids &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;junction_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'HydroID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        hydro_ids&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; hydro_id &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; hydro_ids&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# Using junction layer even with filter applied results in all points used,&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# so send the junction to a temporary feature class for use in tracing&lt;/SPAN&gt;
    start_pt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;conversion&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FeatureClassToFeatureClass&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
        in_features&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;junction_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        out_path&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'memory'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        out_name&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'current_junction'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        where_clause&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'HydroID = '&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;hydro_id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    Updated_Trace_Network &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;tn&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Trace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
        in_trace_network&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;network&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        trace_type&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'UPSTREAM'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        starting_points&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;start_pt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        condition_barriers&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'HydroID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'DOES_NOT_EQUAL'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SPECIFIC_VALUE'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; hydro_id&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'OR'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        traversability_scope&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'JUNCTIONS_ONLY'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; Updated_Trace_Network&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;edge_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'JunctionID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;
            &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                count &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;# Should be a selected subset, but we're getting the entire feature class&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Edges: '&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SetParameter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; edge_layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:23:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35986#M4</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2021-12-10T21:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35987#M5</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure of the brackets for some of those?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where clause - is hydro_id a list you get the index 0 from?&lt;/P&gt;&lt;P&gt;condition_barriers - looks funky, brackets and list in a list, as well as the [0] also?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if condition barriers is wrong wouldn't that cause what you're experiencing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2020 21:33:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35987#M5</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-11-06T21:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35988#M6</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hydro_id is a number, like 1392.&amp;nbsp; It's used to create a whereclause like "HydroID = 1392".&amp;nbsp; I use hydro_id to uniquely identify each feature in my feature class.&amp;nbsp; It's unique like ObjectID, but I have control over it.&amp;nbsp; In line 24, whereclause is one of the optional arguments in the FeatureClassToFeatureClass function that is called on line 20.&amp;nbsp; There is a closing paren on line 24 that completes the function.&amp;nbsp; Geoprocessing tools can return one or more outputs, so the [0] is grabbing the first output, which is the output feature class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The same thing goes for the [0] bracket at the end of the arcpy.tn.Trace call that starts on line 25.&amp;nbsp; I think condition barriers is right.&amp;nbsp; I created that code by exporting it as a Python script from a working GP Model in ModelBuilder, and then tweaking it to run as a script tool.&amp;nbsp; Also, you can have multiple conditions, and each condition has a list of parameters, so the conditions argument is a list of conditions, i.e., a list of lists.&amp;nbsp; In my case, I only have one condition, so the outer list only has one element in it (the inner list), and I can see how that looks funny.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even if those condition barriers were wrong, if it didn't cause an error, the worst it would do is to make all upstream edges be selected instead of just the ones between the starting point and the nearest upstream barriers.&amp;nbsp; However, even downstream edges are included in that search cursor on line 32, so it's like the layer isn't yet seeing the selection from the network trace.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I observed that as the tool executes, I do see the selections from each trace happening in the map, and when the tool finishes, the selection from the last trace is still there.&amp;nbsp; But, the edge layer as seen by the code doesn't see that selection; ditto when run within an iterator in ModelBuilder.&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2020 22:03:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35988#M6</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2020-11-06T22:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35989#M7</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're very patient Tim, I see now (so used referencing the variables before the tool).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm also still confused about what's going on! I'll leave this to the smart people.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2020 22:25:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35989#M7</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-11-06T22:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35990#M8</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;I'm thinking the only recourse until 2.7 is released, is to output an aggregated feature and then use a spatial filter to select the appropriate edges&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;That's what I wound up doing.&amp;nbsp; I used Python rather than ModelBuilder because I find it easier to follow.&amp;nbsp; Some example code is below.&amp;nbsp; I also heard Arc Hydro is using trace networks now, so I will peak at their code later.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this to work, I have to deal with the fact that when I copy a given junction to a new feature class to use as a starting point, when I perform an upstream trace, the trace tends to also include the edge just downstream of that junction.&amp;nbsp; Before running the code below, I precompute length downstream to the network outlet for each junction, and also from the downstream end of each edge.&amp;nbsp; If an edge has a length downstream value less than the junction, then it is downstream from the junction.&amp;nbsp; I only want upstream edges.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Updated_Trace_Network &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;tn&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Trace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
    in_trace_network&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;network&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    trace_type&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'UPSTREAM'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    starting_points&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;start_pt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    validate_consistency&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'DO_NOT_VALIDATE_CONSISTENCY'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## proceed even if we've updated other features&lt;/SPAN&gt;
    condition_barriers&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'HydroID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'DOES_NOT_EQUAL'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SPECIFIC_VALUE'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; hydro_id&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'OR'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    traversability_scope&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'JUNCTIONS_ONLY'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    result_types&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'AGGREGATED_GEOMETRY'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    trace_name&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;hydro_id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    aggregated_lines&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;agg_lines&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; Updated_Trace_Network&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# Select the edges corresponding to the aggregated trace result&lt;/SPAN&gt;
    lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByLocation_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
        edge_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SHARE_A_LINE_SEGMENT_WITH'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; agg_lines&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    edge_count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; edge_count &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;# Sometimes downstream edges are selected. Remove them.&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
            lyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SUBSET_SELECTION'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'LengthDown &amp;gt;= '&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;length_down&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        edge_count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; edge_count &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Upstream edge count: '&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;edge_count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateField_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'JunctionID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; hydro_id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'No upstream edges found'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'No upstream edges found'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:23:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/35990#M8</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2021-12-10T21:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1006408#M47</link>
      <description>&lt;P&gt;I figured out how to prevent the downstream edge from being returned in the upstream trace.&amp;nbsp; My mistake was simply copying my selected junction to a separate flag feature class.&amp;nbsp; To make this work, I also have to add and populate a couple of fields that you'll notice in the TN_Temp_Starting_Points feature class in your default geodatabase that stores the flags you create interactively (via Data tab on ribbon), namely, SOURCEID and FEATUREGLOBALID.&amp;nbsp; The SOURCEID refers to the identifier given to the junction layer in the trace network.&amp;nbsp; The FEATUREGLOBALID is the GLOBALID of the junction feature where you want the starting point placed.&amp;nbsp; I wish this information had been in a white paper that I had access to.&lt;/P&gt;&lt;P&gt;Here's code that demonstrates how to trace upstream given a junction layer.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy


def get_source_id(network, network_layer):
    d = arcpy.Describe(network_layer)
    fc_name = d.featureClass.name
    
    d = arcpy.Describe(network)
    for s in d.sources:
        if s.name == fc_name:
            return s.sourceID

    arcpy.AddError(
        'Could not determine network source ID for ' + network_layer.name)
    raise arcpy.ExecuteError


def point_to_flag(shape_xy, spatial_ref, source_id, global_id):
    flag_fc = arcpy.CreateFeatureclass_management(
        out_path='memory',
        out_name='flag',
        geometry_type='POINT',
        has_m='ENABLED',
        has_z='ENABLED',
        spatial_reference=spatial_ref)[0]
    flag_fc = arcpy.management.AddField(flag_fc, 'SOURCEID', 'LONG')[0]
    flag_fc = arcpy.management.AddField(flag_fc, 'FEATUREGLOBALID', 'GUID')[0]
    fields = ['SHAPE@XY', 'SOURCEID', 'FEATUREGLOBALID']
    with arcpy.da.InsertCursor(flag_fc, fields) as cursor:
        cursor.insertRow((shape_xy, source_id, global_id))
    return flag_fc


arcpy.env.overwriteOutput = True

network = arcpy.GetParameter(0)
junction_layer = arcpy.GetParameter(1)

spatial_ref = arcpy.Describe(junction_layer).spatialReference
source_id = get_source_id(network, junction_layer)

with arcpy.da.SearchCursor(junction_layer, ['SHAPE@XY', 'GLOBALID']) as cursor:
    for i, row in enumerate(cursor):        
        flag = point_to_flag(row[0], spatial_ref, source_id, row[1])

        Updated_Trace_Network = arcpy.tn.Trace(
            in_trace_network=network,
            trace_type='UPSTREAM',
            starting_points=flag)[0]

arcpy.SetParameter(2, junction_layer)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, until Pro 2.7 is released in which the trace tools return selection layers, the keys to iterating traces are:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a point feature class for your starting point(s), and populate SOURCEID and&amp;nbsp; FEATUREGLOBALID attributes in that feature class.&lt;/LI&gt;&lt;LI&gt;Return aggregated geometry, and use that geometry to select features from your network layer(s).&lt;/LI&gt;&lt;LI&gt;If you're updating a network layer's attributes while iterating, when you call arcpy.tn.Trace remember to set validate_consistency='DO_NOT_VALIDATE_CONSISTENCY' so the tool executes even as you update features.&lt;/LI&gt;&lt;LI&gt;Run arcpy.ValidateNetworkTopology_tn when you need to validate the network after updating it.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I've implemented this via Python. It seems like it should also work via ModelBuilder iteration, but ModelBuilder iteration confuses me, so I haven't verified it works there.&amp;nbsp; My id_to_edges.py script, and the utils.py script it relies on, are attached in case folks find it helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 22:03:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1006408#M47</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2020-12-02T22:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1108928#M85</link>
      <description>&lt;P&gt;Hi Tim,&lt;/P&gt;&lt;P&gt;I use ArcGIS Pro 2.7.2. In ArcGIS Pro Trace geoprocessing tool works as expected and selects some network elements. I have copied Python script and placed it in my application, but I don't know how to get selection from it.&amp;nbsp;I have checked all results of&amp;nbsp;arcpy.tn.Trace and my selection must be in element number 2.&amp;nbsp; My python script:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    result = arcpy.tn.Trace(traceNetworkDataset, "UPSTREAM", startPointsFC, None, "NO_DIRECTION", '', "EXCLUDE_BARRIERS",
                            "DO_NOT_VALIDATE_CONSISTENCY", "DO_NOT_IGNORE_BARRIERS_AT_STARTING_POINTS", "IGNORE_INDETERMINATE_FLOW",
                            None, None, "BOTH_JUNCTIONS_AND_EDGES", None, None, "SELECTION", "NEW_SELECTION", "CLEAR_ALL_PREVIOUS_TRACE_RESULTS", '',
                            "Trace_Results_Aggregated_Points", "Trace_Results_Aggregated_Lines", None, "DO_NOT_USE_TRACE_CONFIGURATION", '')&lt;/LI-CODE&gt;&lt;P&gt;Your scripts don't use selection but maybe you know how to get it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 17:27:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1108928#M85</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-10-19T17:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1109018#M86</link>
      <description>&lt;P&gt;My code worked in 2.7, so I did not bother revising it to take advantage of the new selection functionality, so I cannot give you concrete advice on how to deal with network trace results as selections.&lt;/P&gt;&lt;P&gt;Still, it seems the selection should be present on the feature layer when the trace is finished running.&amp;nbsp; This means the next time you access the network layer in your script or geoprocessing workflow, the selection should be there.&amp;nbsp; However, I have not tested this, so maybe I'm missing something.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 21:43:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1109018#M86</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2021-10-19T21:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate traces and feature selections</title>
      <link>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1502323#M165</link>
      <description>&lt;P&gt;I created a feature layer of the network feature service from the published Trace Network&lt;/P&gt;&lt;P&gt;trace_network = "https://..../WNetwork/FeatureServer/8"&lt;BR /&gt;network = "https://..../WNetwork/FeatureServer/1"&lt;/P&gt;&lt;P&gt;arcpy.management.MakeFeatureLayer(network,"net_layer")&lt;/P&gt;&lt;P&gt;arcpy.tn.Trace(in_trace_network=trace_network,trace_type="CONNECTED",starting_points=source,barriers=barriers,path_direction="NO_DIRECTION",shortest_path_network_attribute_name="",include_barriers="INCLUDE_BARRIERS",validate_consistency="VALIDATE_CONSISTENCY",ignore_barriers_at_starting_points="DO_NOT_IGNORE_BARRIERS_AT_STARTING_POINTS",allow_indeterminate_flow="IGNORE_INDETERMINATE_FLOW",condition_barriers=None,function_barriers=None,traversability_scope="BOTH_JUNCTIONS_AND_EDGES",functions=None,output_conditions=None,result_types="SELECTION",selection_type="NEW_SELECTION",clear_all_previous_trace_results="CLEAR_ALL_PREVIOUS_TRACE_RESULTS",trace_name="",aggregated_points="Trace_Results_Aggregated_Points",aggregated_lines="Trace_Results_Aggregated_Lines",out_network_layer=None,use_trace_config="DO_NOT_USE_TRACE_CONFIGURATION",trace_config_name="",out_json_file=None)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then just referenced the feature layer in few calculate fields and selection switch using SelectLayerByAttribute&lt;/P&gt;&lt;P&gt;# calculate field --&amp;gt; available pipes in network as determined by the trace of the network&lt;BR /&gt;arcpy.management.CalculateField(in_table="net_layer",field="STATUS",expression='"Avaliable"',expression_type="PYTHON3",code_block="",field_type="TEXT",enforce_domains="NO_ENFORCE_DOMAINS")&lt;/P&gt;&lt;P&gt;# switch selection --&amp;gt; unavailable pipes in network&lt;BR /&gt;arcpy.management.SelectLayerByAttribute(in_layer_or_view="net_layer",selection_type="SWITCH_SELECTION",where_clause="",invert_where_clause=None)&lt;BR /&gt;&lt;BR /&gt;# calculate field --&amp;gt; unavailable pipes in network&lt;BR /&gt;arcpy.management.CalculateField(in_table="net_layer",field="STATUS",expression='"Unavaliable"',expression_type="PYTHON3",code_block="",field_type="TEXT",enforce_domains="NO_ENFORCE_DOMAINS")&lt;/P&gt;&lt;P&gt;Hopefully this will be useful to someone.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Elliott&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 11:11:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/how-to-iterate-traces-and-feature-selections/m-p/1502323#M165</guid>
      <dc:creator>ECarson</dc:creator>
      <dc:date>2024-07-08T11:11:32Z</dc:date>
    </item>
  </channel>
</rss>

