mxd = arcpy.mapping.MapDocument ("CURRENT")
df = arcpy.mapping.ListDataFrames (mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, df)
EW = arcpy.GetParameter(0)
NS = arcpy.GetParameter(1)
#orig extent
ext = lyr.extent
#mods
ext.XMin += EW
ext.XMax += EW
ext.YMin += NS
ext.YMax += NS
#new extent
lyr.extent = ext
rai = arcpy.mapping.ListLayers(mxd, "Railroads", df)[0] EW = arcpy.GetParameter(0) NS = arcpy.GetParameter(1) with arcpy.da.UpdateCursor(rai, ['OID@', 'SHAPE@X', 'SHAPE@Y']) as cursor: EWmove = 0 NSmove = 0 for row in cursor: if row[1] >= '0': cursor.updateRow(row) elif row[2] >= '0': cursor.updateRow(row) else: arcpy.AddMessage("Feature(s) not moved")
import arcpy rai = arcpy.mapping.ListLayers(mxd, "Railroads", df)[0] EWmove = float(arcpy.GetParameter(0)) NSmove = float(arcpy.GetParameter(1)) update_cursor = arcpy.da.UpdateCursor(rai, 'SHAPE@') for row in update_cursor: array = arcpy.Array() for part in row[0]: for point in part: point.X += EWmove point.Y += NSmove array.add(point) new_line = arcpy.Polyline(array) row[0] = new_line update_cursor.updateRow(row) del update_cursor
with arcpy.da.UpdateCursor(in_features, ['SHAPE@XY']) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + (x_shift or 0), row[0][1] + (y_shift or 0)]])
You don't actually have to update each vertex according to the Café Python page..
http://arcpy.wordpress.com/page/2/
just update the SHAPE@XY token instead, then the whole feature moves.
like :with arcpy.da.UpdateCursor(in_features, ['SHAPE@XY']) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + (x_shift or 0), row[0][1] + (y_shift or 0)]])
Cheers,
Neil