<?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: Function outputs? in Trace Network Questions</title>
    <link>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/174484#M10</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently, the function results are only in the messages. You could use the &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/functions/getmessages.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/functions/getmessages.htm"&gt;GetMessages—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;to get the function result and store the value in an attribute.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Supriya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Sep 2020 18:12:02 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-09-29T18:12:02Z</dc:date>
    <item>
      <title>Function outputs?</title>
      <link>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/174483#M9</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What can you do with the output of functions in a trace?&amp;nbsp; Do they show up anywhere besides the Messages window?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm particularly interested in a model builder use - I'd like to iterate through a set of features, run a trace on each of them, and store the results of the function in an attribute.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Sep 2020 18:27:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/174483#M9</guid>
      <dc:creator>BenCoakley1</dc:creator>
      <dc:date>2020-09-24T18:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Function outputs?</title>
      <link>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/174484#M10</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently, the function results are only in the messages. You could use the &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/functions/getmessages.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/functions/getmessages.htm"&gt;GetMessages—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;to get the function result and store the value in an attribute.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Supriya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:12:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/174484#M10</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-09-29T18:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Function outputs?</title>
      <link>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/174485#M11</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm still working on this, trying various approaches.&amp;nbsp; First, I can confirm that the function outputs don't show up in the Python results either:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;result=arcpy.Trace_tn(in_trace_network=tnet, trace_type="UPSTREAM", starting_points='mhsel', barriers=tntb, result_types="SELECTION", selection_type="NEW_SELECTION", functions=[["ADD", "Shape length"]])
print(result)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;just returns&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Trace_Results_Aggregated_Points&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;But I'm also having a hard time figuring out how to work with the results of a trace in Python.&amp;nbsp; In the above code, I've specified that the result type should be a SELECTION, but the Results variable shows aggregated points.&amp;nbsp; And if I work with the feature classes that make up the trace network after performing the trace, there doesn't seem to be an active selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a look at more of the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# -*- coding: utf-8 -*-

import arcpy

arcpy.env.workspace = "C:\\Path\\clean trace network.gdb"
arcpy.env.overwriteOutput = True 

mhfc = "C:\\Path\\clean trace network.gdb\\sewer_trace\\Manholes"
scfc = "C:\\Path\\clean trace network.gdb\\sewer_trace\\ServiceConnections"
gmfc = "C:\\Path\\clean trace network.gdb\\sewer_trace\\GravityMains"
llfc = "C:\\Path\\clean trace network.gdb\\sewer_trace\\Laterals"

mhfields = ['NAME', 'SHAPE@']

tnet = "C:\\Path\\clean trace network.gdb\\sewer_trace\\sewer_tn"
tntb = "C:\\Path\\clean trace network.gdb\\TN_Temp_Barriers"


print('Beginning')
result = arcpy.GetCount_management(mhfc)
print(' Manhole count: ', result[0])
result = arcpy.GetCount_management(scfc)
print(' Service Connection count: ', result[0])
result = arcpy.GetCount_management(gmfc)
print(' Gravity Main count: ', result[0])
result = arcpy.GetCount_management(llfc)
print(' Lateral Line count: ', result[0])


with arcpy.da.SearchCursor(mhfc, mhfields) as cursor:
    for row in cursor:
        print(row[0])
        querystring = "NAME = '"+row[0]+"'"
        print(querystring)
        arcpy.MakeFeatureLayer_management(mhfc, 'mhsel', querystring)
        result = arcpy.GetCount_management('mhsel')
        print(' Selected manholes in filter: ', result[0])
        result=arcpy.Trace_tn(in_trace_network=tnet, trace_type="UPSTREAM", starting_points='mhsel', barriers=tntb, result_types="SELECTION", selection_type="NEW_SELECTION", functions=[["ADD", "Shape length"]])
        print(result)
        result = arcpy.GetCount_management(mhfc)
        print(' Manhole count: ', result[0])
        result = arcpy.GetCount_management(scfc)
        print(' Service Connection count: ', result[0])
        result = arcpy.GetCount_management(gmfc)
        print(' Gravity Main count: ', result[0])
        result = arcpy.GetCount_management(llfc)
        print(' Lateral Line count: ', result[0])&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This gives results like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Beginning
 Manhole count: 1853
 Service Connection count: 2815
 Gravity Main count: 1810
 Lateral Line count: 2815
Manhole1
NAME = 'Manhole1'
 Selected manholes in filter: 1
Trace_Results_Aggregated_Points
 Manhole count: 1853
 Service Connection count: 2815
 Gravity Main count: 1810
 Lateral Line count: 2815
Manhole2
NAME = 'Manhole2'
 Selected manholes in filter: 1
Trace_Results_Aggregated_Points
 Manhole count: 1853
 Service Connection count: 2815
 Gravity Main count: 1810
 Lateral Line count: 2815
Manhole3
NAME = 'Manhole3'
 Selected manholes in filter: 1
Trace_Results_Aggregated_Points
 Manhole count: 1853
 Service Connection count: 2815
 Gravity Main count: 1810
 Lateral Line count: 2815&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;That is, the number of features in the results doesn't change.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(I also tried a slightly different approach for the trace, using the SHAPE@ field of the cursor as the starting points, but the results were similar.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the trace manually in ArcGIS Pro for Manhol1 shows 29 selected manholes, 22 selected service connections, 29 selected gravity mains, and 22 selected laterals.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I missing here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:08:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/174485#M11</guid>
      <dc:creator>BenCoakley1</dc:creator>
      <dc:date>2021-12-12T16:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Function outputs?</title>
      <link>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/1108816#M84</link>
      <description>&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;Have you succeeded with trace results?&amp;nbsp;&lt;/P&gt;&lt;P&gt;From ArcGIS&amp;nbsp; Pro trace selects features what I need&amp;nbsp; but from python I don't know how to make the same selection.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 14:16:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/function-outputs/m-p/1108816#M84</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-10-19T14:16:03Z</dc:date>
    </item>
  </channel>
</rss>

