<?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 Route feature class not respecting selected features in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/route-feature-class-not-respecting-selected/m-p/477582#M37394</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a python script tool that runs fine against all features in a Route Event Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, if I graphically select a subset of features, it iterates through the first record and not the rest.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I export the Route Event Layer to a stand-alone feature class in a file geodatabase it works fine against a selected set of features, iterating through (SUMing) the entire set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why won't the script respect, or properly iterate through, a selected set of records in a Route Event Layer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Name: Sum_Measures.py
# Import system modules
import arcpy
from arcpy

# Define attribute fields and desired statistcal metrics
statsFields = [["FROM_FT", "SUM"],["TO_FT", "SUM"]]

inRoads = arcpy.GetParameterAsText(0) #Route Feature Class
outStatsTable = arcpy.GetParameterAsText(1) # Table to be created with summed lengths

# Execute Statistics to get the area of each vegetation type within
arcpy.Statistics_analysis(inRoads, outStatsTable, statsFields)

# Create a search cursor 
rows = arcpy.SearchCursor(outStatsTable)
fields = arcpy.ListFields(outStatsTable)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field.name == "SUM_FROM_FT":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(row.getValue(field.name)))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM_M = row.getValue(field.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif field.name == "SUM_TO_FT":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(row.getValue(field.name)))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TO_M = row.getValue(field.name)

TOT_DIST_MI = ((TO_M - FROM_M) / 5280)
arcpy.AddMessage("Total Distance = " + str(TOT_DIST_MI) + " miles")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 May 2011 17:37:24 GMT</pubDate>
    <dc:creator>markjoselyn</dc:creator>
    <dc:date>2011-05-09T17:37:24Z</dc:date>
    <item>
      <title>Route feature class not respecting selected features</title>
      <link>https://community.esri.com/t5/python-questions/route-feature-class-not-respecting-selected/m-p/477582#M37394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a python script tool that runs fine against all features in a Route Event Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, if I graphically select a subset of features, it iterates through the first record and not the rest.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I export the Route Event Layer to a stand-alone feature class in a file geodatabase it works fine against a selected set of features, iterating through (SUMing) the entire set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why won't the script respect, or properly iterate through, a selected set of records in a Route Event Layer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Name: Sum_Measures.py
# Import system modules
import arcpy
from arcpy

# Define attribute fields and desired statistcal metrics
statsFields = [["FROM_FT", "SUM"],["TO_FT", "SUM"]]

inRoads = arcpy.GetParameterAsText(0) #Route Feature Class
outStatsTable = arcpy.GetParameterAsText(1) # Table to be created with summed lengths

# Execute Statistics to get the area of each vegetation type within
arcpy.Statistics_analysis(inRoads, outStatsTable, statsFields)

# Create a search cursor 
rows = arcpy.SearchCursor(outStatsTable)
fields = arcpy.ListFields(outStatsTable)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field.name == "SUM_FROM_FT":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(row.getValue(field.name)))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM_M = row.getValue(field.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif field.name == "SUM_TO_FT":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(row.getValue(field.name)))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TO_M = row.getValue(field.name)

TOT_DIST_MI = ((TO_M - FROM_M) / 5280)
arcpy.AddMessage("Total Distance = " + str(TOT_DIST_MI) + " miles")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 May 2011 17:37:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/route-feature-class-not-respecting-selected/m-p/477582#M37394</guid>
      <dc:creator>markjoselyn</dc:creator>
      <dc:date>2011-05-09T17:37:24Z</dc:date>
    </item>
  </channel>
</rss>

