ArcMap 10.7.1 (Oracle SDE.ST_GEOMETRY):
I want to use the Calculate Field GP tool to update the coordinates of a polyline FC's shape column.
I have a script that works in a standalone Python IDE (PyScripter):
import arcpy connection = "Database Connections\my_conn.sde" feature_class = connection + "\my_owner.my_fc" spatial_reference = arcpy.Describe(feature_class).spatialReference with arcpy.da.Editor(connection) as edit_session: with arcpy.da.UpdateCursor(feature_class, "SHAPE@") as cursor: for row in cursor: geometry = row.densify("ANGLE", 10000, 0.174533) parts = arcpy.Array() for part in geometry: points = arcpy.Array() for point in part: point.M = geometry.measureOnLine(point) points.append(point) parts.append(points) row = arcpy.Polyline(parts, spatial_reference) cursor.updateRow(row)
I want to use that same logic, but in the Calculate Field GP tool:
Expression: ----------- new_shape( !SHAPE! ) Code Block: ----------- def new_shape(geometry): geometry = geometry.densify("ANGLE", 10000, 0.174533) parts = arcpy.Array() for part in geometry: points = arcpy.Array() for point in part: point.M = geometry.measureOnLine(point) points.append(point) parts.append(points) return arcpy.Polyline(parts)
When I run that Calculate Field code, I get an error:
"geoprocessing describe geometry object' object is not iterable"
ERROR 000539: Error running expression: new_shape( GPVARIANTOBJECT0 ) Traceback (most recent call last): File "<expression>", line 1, in <module> File "<string>", line 4, in new_shape TypeError: 'geoprocessing describe geometry object' object is not iterable Failed to execute (CalculateField).
What am I doing wrong?
The geometry was iterable when using the full blown script in PyScripter. I don't understand why it isn't iterable in the Calculate Field script too.