Route feature class not respecting selected features

703
0
05-09-2011 10:37 AM
markjoselyn
New Contributor
Greetings,
I have a python script tool that runs fine against all features in a Route Event Layer.
However, if I graphically select a subset of features, it iterates through the first record and not the rest.

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.

Why won't the script respect, or properly iterate through, a selected set of records in a Route Event Layer?

# 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:
    for field in fields:
        if field.name == "SUM_FROM_FT":
            arcpy.AddMessage(str(row.getValue(field.name)))
            FROM_M = row.getValue(field.name)
        elif field.name == "SUM_TO_FT":
            arcpy.AddMessage(str(row.getValue(field.name)))
            TO_M = row.getValue(field.name)

TOT_DIST_MI = ((TO_M - FROM_M) / 5280)
arcpy.AddMessage("Total Distance = " + str(TOT_DIST_MI) + " miles")
Tags (2)
0 Kudos
0 Replies