Regarding the field calculator in the ArcGIS Pro 2.9 attribute table (Python):
Is there a way to skip calculating a certain record, if certain conditions are met in the script?
For example, if the line doesn't have true curves, then calculate the shape normally. But if the line does have true curves, then skip the field calculation — without editing the row/invoking editor tracking.
I can do something that's close to that. I can return the original value. That works, but it does update the row, which seems unnecessary and invokes editor tracking (which is misleading, since nothing's really changed).
return orig_geom
Alternatively, I've tried return
without specifying anything to return. But that sets the shape to null, which isn't what I want.
return
The same thing happens if I omit the return
entirely. The shape gets set to null.
I know it would be ideal if I could avoid selecting lines with curves in the first place (in the Attribute Table). But I don't think there's a way to query for curves using SQL in the Select By Attributes tool. So doing it in the field calculator script seems like the only other option.
Related ArcGIS Pro Idea: Conditionally skip field calculation for certain rows
return
,return None
, and omitting any return are all equivalent in Python, so that behavior makes sense. Have you tried using anUpdateCursor
instead? You could omitupdateRow()
as necessaryarcpy.da.UpdateCursor()
. You can use awhere
cause to skip rows when the cursor is established, OR you can simply not update a row, one-at-a-time (while iterating through them), as it suits your requirements.