AnsweredAssumed Answered

How to: Read value from "Shape_Length" field, create table that increments from 0 to "Shape_Length" value.

Question asked by connor.mcivor@fluor.com on Jun 4, 2020
Latest reply on Jun 16, 2020 by mark.bryant

Hello,

 

I am writing a script and a portion of said script requires that I build a table that starts at 0 and increments by 1 until reaching the value of "Shape_Length" from a feature class. I have line work that I wish to read the "Shape_Length" from and I am having troubles getting the syntax correct.

Route = arcpy.CreateRoutes_lr(Input_Linework, Linework_Field, Output_Name)

# Store value in SHAPE_LENGTH from Route
with arcpy.da.SearchCursor(Route, ['Shape_Length']) as cursor:
    for row in Cursor:
        Max_Value   = row.getValue('Shape_Length')
del row
del cursor
   
# Create table with two fields, RouteID and Chainage
Route_Table     = arcpy.CreateTable_management(str(Output_WS), Output_Name))

# Append additional rows to table in increments of 1 and end at the exact value of
# the Max_Value
fields          = ['RouteID', 'Chainage']
Pop_Table       = arcpy.da.InsertCursor(Route_Table, fields)
for x in range(0, Max_Value):
    Pop_Table.insertRow(str(Linework_Field), x)
del x

I get an error on line 6:

AttributeError: 'tuple' object has no attribute 'getValue'

 

I have tried reading through the page:

Accessing data using cursors—Help | ArcGIS Desktop 

I messed around with the code a bit but this is where I am at now and can't determine how to move forward.

Outcomes