HiFor a featureclass of polylines with 2 vertices each, I want to be able to keep the line itself, startpoint and the angle, but move endpoint to a specific length.I am doing this in a versioned geodatabase, and currently I can put a new line into the geometry, but the problem is, there are featurelinked annotations which are reset, when the whole line is changed.I wonder whether it is possible, since I already am in edit mode, to just move lastpoint of the existing line?Perhaps this is not possible with arcpy?Best RegardsMarianne Wiese
import arcpy, time, traceback
arcpy.env.workspace = 'Database Connections/mbw.sde'
inFeatures = 'G100.geopoint_mbw_20130930/G100.geopoint_line_2'
newLength = 550
n = 0
try:
uCursor = arcpy.da.UpdateCursor(inFeatures, [ 'OID@', 'SHAPE@'])
edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing()
edit.startOperation()
for row in uCursor:
line = row[1]
factor = newLength/line.length
X2 = line.firstPoint.X + factor * (line.lastPoint.X - line.firstPoint.X)
Y2 = line.firstPoint.Y + factor * (line.lastPoint.Y - line.firstPoint.Y)
array = arcpy.Array([line.firstPoint, arcpy.Point(X2,Y2)])
newLine = arcpy.Polyline(array)
row[1] = newLine
uCursor.updateRow(row)
n += 1
if (n % 1000 == 0):
print time.strftime('%H:%M:%S'), ': ', n
except:
tb = traceback.format_exc()
print tb
finally:
del uCursor
edit.stopOperation()
edit.stopEditing(True)
del edit
print 'all done'