import os import arcpy def RadiusTable(tbl,rc): arcpy.AddField_management(tbl,"RADIUS","FLOAT") rc = ";".split(rc) Rows = arcpy.UpdateCursor(tbl) k = 0 for Row in Rows: Row.setValue("RADIUS",rc) k += 1 del Row, Row return tbl
I get this error when trying to run:ERROR 000539: Error running expression: AddRadiusField(r"Z:\Scratch\1303\130114_temp1.dbf","%RadiusColumns%") <type 'exceptions.NameError'>: name 'AddRadiusField' is not definedFailed to execute (Calculate Value).
import os import arcpy def RadiusTable(rc,tbl): arcpy.AddField_management(tbl,"RADIUS","FLOAT") rc = ";".split(rc) Rows = arcpy.UpdateCursor(tbl) k = 0 for Row in Rows: Row.setValue("RADIUS",rc) k += 1 del Row, Row return tbl
Expression:AddRadiusField(r"%OutputTable%","%RadiusColumns%")Code block: Code: import os import arcpy def RadiusTable(rc,tbl): arcpy.AddField(tbl,"RADIUS","FLOAT") rc = ";".split(rc) Rows = arcpy.UpdateCursor(tbl) k = 0 for Row in Rows: Row.setValue("RADIUS",rc) k += 1 del Row, Row return tbl Data Type: table
Code: import os import arcpy def RadiusTable(rc,tbl): arcpy.AddField(tbl,"RADIUS","FLOAT") rc = ";".split(rc) Rows = arcpy.UpdateCursor(tbl) k = 0 for Row in Rows: Row.setValue("RADIUS",rc) k += 1 del Row, Row return tbl
After reading up on how inline model variables and iterators work, I am thinking I need to change all the blue ovals ("Seach Radius") to "RadiusColumns" as defined in your expression. But I am unable to duplicate this label since model builder only allows unique names. Also, Following your suggestions would allow me to delete the 'collect values' tool at the top, yes?
Thanks again Curtis,
Expression:AddRadiusField(r"%OutputTable%","%RadiusColumns%")
I've tried the merge, union and calculate values tool to somehow bring it all together, but no luck.
import os import arcpy def RadiusTable(rc,tbl): arcpy.AddField(tbl,"RADIUS","FLOAT") rc = ";".split(rc) Rows = arcpy.UpdateCursor(tbl) k = 0 for Row in Rows: Row.setValue("RADIUS",rc) k += 1 del Row, Row return tbl
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.