Select to view content in your preferred language

Snap a point that was added by code

02-21-2022 10:05 PM
Occasional Contributor III

I am using my own tool to add points by user.

The code takes the point clicked by the user. Do some stuff and add it to the feature class.

I would like to snap the point just like it was added with the create feature standard tool.

Is there any way to take a geometry in the code and snap it by the current snap env?


0 Kudos
1 Reply
Esri Regular Contributor


In the constructor of your tool you need to add line :

UseSnapping = true;

Then in the "OnSketchCompleteAsync" create feature using EditOperation Create method:

// Create an edit operation
var createOperation = new EditOperation();
createOperation.Name = string.Format("Create {0}", layer.Name);
createOperation.SelectNewFeatures = true;
// Queue feature creation
createOperation.Create(layer, geometry);
return createOperation.Execute();
0 Kudos