I'm trying to build a tool based on script in arcgis pro (the tool makes changes to a field with calculate field based on a list of variables). how do i use a list inserted with arcpy.GetParameterAsText() within a codeblock function in calculate field ?
my problem is that it does not recognize my list: "NameError: name 'surv_list' is not defined"
This is my script:
import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"C:\GIS\project_prebuild.gdb"
# Exmaple fot text input to run tool in python:
##surv_list = (('FT18-17',235,300),('FT18-17',410,432),('FT18-15',101,130),('FT18-13',101,140))
surv_list = arcpy.GetParameterAsText(0)
record_list = arcpy.GetParameterAsText(1)
codeblock = ("""def update_status(line,point,surv_list,record_list):
if len(surv_list[0])==3:
for x in surv_list:
if line == x[0] and point >= x[1] and point <= x[2]:
return 1
elif line == surv_list[0] and point >= surv_list[1] and point <= surv_list[2]:
return 1
if len(record_list[0])==3:
for y in record_list:
if line == y[0] and point >= y[1] and point <= y[2]:
return 2
elif line == record_list[0] and point >= record_list[1] and point <= record_list[2]:
return 2""")
arcpy.CalculateField_management("REC_Preplot_25m","Status","update_status(!LineNumber!,!Station!,surv_list,record_list)","PYTHON3",codeblock)