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] EWmove = float(arcpy.GetParameter(0)) NSmove = float(arcpy.GetParameter(1)) def shift_features(in_features, EWmove=None, NSmove=None): in_features = rai point.X += EWmove point.Y += NSmove with arcpy.da.UpdateCursor(rai, ['SHAPE@XY']) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + (EWmove or 0), row[0][1] + (NSmove or 0)]]) return arcpy.RefreshActiveView()
rai = arcpy.mapping.ListLayers(mxd, "Railroads", df)[0] EWmove = float(arcpy.GetParameter(0)) NSmove = float(arcpy.GetParameter(1)) def shift_features(in_features, EWmove=None, NSmove=None): in_features = rai point.X += EWmove point.Y += NSmove with arcpy.da.UpdateCursor(rai, ['SHAPE@XY']) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + (EWmove or 0), row[0][1] + (NSmove or 0)]]) return arcpy.RefreshActiveView()
rai = arcpy.mapping.ListLayers(mxd, "Railroads", df)[0] EWmove = float(arcpy.GetParameter(0)) NSmove = float(arcpy.GetParameter(1)) def shift_features(in_features, EWmove=None, NSmove=None): rai = in_features with arcpy.da.UpdateCursor(rai, ['SHAPE@XY']) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + (EWmove), row[0][1] + (NSmove)]]) return arcpy.RefreshActiveView()
rai = arcpy.mapping.ListLayers(mxd, "Railroads", df)[0] EWmove = float(arcpy.GetParameter(0)) NSmove = float(arcpy.GetParameter(1)) def shift_features(in_features, EWmove=None, NSmove=None): in_features = rai point.X += EWmove point.Y += NSmove with arcpy.da.UpdateCursor(rai, ['SHAPE@XY']) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + (EWmove or 0), row[0][1] + (NSmove or 0)]]) return arcpy.RefreshActiveView()
shouldn't this be...rai = arcpy.mapping.ListLayers(mxd, "Railroads", df)[0] EWmove = float(arcpy.GetParameter(0)) NSmove = float(arcpy.GetParameter(1)) def shift_features(in_features, EWmove=None, NSmove=None): rai = in_features with arcpy.da.UpdateCursor(rai, ['SHAPE@XY']) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + (EWmove), row[0][1] + (NSmove)]]) return arcpy.RefreshActiveView()
Cheers,
Neil