0

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.

0

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

0

I think I just found a solution myself. I was already close. As stated above ToPoint.PutCoords doesn't work. But I could use this:

polyline = feature.ShapeCopy as IPolyline;
polyline.ToPoint = _connectionPoint
feature.Shape = polyline as IGeometry;
feature.Store();

maybe this is helpful for others looking for a simple way how to edit a polyline (end)vertex.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.