[GIS] How to move an endpoint of a polyline feature to specific coordinates

arcobjectsc

What looked like a simple task has kept me busy for a while now. I would like to snap the endpoint of a polyline feature to a known point of which I know the coordinates.

My first try was the following (within an edit operation):

polyline = feature.ShapeCopy as IPolyline;
polyline.ToPoint.PutCoords(_connectionPoint.X, _connectionPoint.Y);
feature.Shape = polyline;
feature.Store();

the new coordinates however would never be saved at the feature.

I also looked at this example:

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_modify_a_specific_vertex_of_a_polyline/000100000023000000/

but I am a bit confused about whether I really need a HitTest in my case.

Best Answer

You need to update the specific point coordinates via IPointCollection.Update.

Related Question