Hi David,
You're nearly there...
I guess the problem is that the row you write should have the same dimensions as the row you read. I renamed the x_shift and y_shift variables to x_new and y_new for readability. I didn't test this, but if I think this could work.
import arcpy
fc = r'c:\yourFGDB.gdb\yourLines'
# update cursor (be careful with this and try it on a copy of your data)
fields = ["SHAPE@","XCentroid","YCentroid"]
with arcpy.da.UpdateCursor(fc,fields) as curs:
for row in curs:
geom = row[0]
x_new = row[1]
y_new = row[2]
array = arcpy.Array()
for part in geom:
lastpnt = part[len(part) - 1]
lastpnt.X = x_new
lastpnt.Y = y_new
part[len(part) - 1] = lastpnt
array.add(part)
curs.updateRow([arcpy.Polyline(array), x_new, y_new])
Kind regards,
Xander
Hello Xander,I am now trying to move the first vertex just like I needed for the last vertex.I have altered the code to the following:import arcpy
fc = r'c:\yourFGDB.gdb\yourLines'
# update cursor (be careful with this and try it on a copy of your data)
fields = ["SHAPE@","XCentroid","YCentroid"]
with arcpy.da.UpdateCursor(fc,fields) as curs:
for row in curs:
geom = row[0]
x_new = row[1]
y_new = row[2]
array = arcpy.Array()
for part in geom:
firstpnt = part[len(part) + 0]
firstpnt.X = x_new
firstpnt.Y = y_new
part[len(part) - 1] = firstpnt
array.add(part)
curs.updateRow([arcpy.Polyline(array), x_new, y_new])
How do you queue the first vertex? My assumption of "firstpnt = part[len(part) + 0]" is wrong.Thank you!David