AnsweredAssumed Answered

Exit condition for SketchEditor

Question asked by hashagen_j on Aug 12, 2018
Latest reply on Aug 15, 2018 by JNery-esristaff

I'm currently facing the problem that I need to add an exit condition for sketching geometries using the SketchEditor. The sketch editor should be finished/completed as soon as the sketched geometry fullfills the condition (e.g. has exactly 4 points).

 

To achieve this I registered to the GeometryChanged event, check for the exit condition and call the CompleteCommand if it mets the condition:

private void SketchEditorOnGeometryChanged(object sender, GeometryChangedEventArgs e)
{
   if (this.CheckValidity(e.NewGeometry) && this.sketchEditor.CompleteCommand.CanExecute(null))
   {
      this.sketchEditor.CompleteCommand.Execute(null);
   }
}

However, the call to CompleteCommand will cause an NullReferenceException, because it will set the geometry of the SketchEditor to null, but the SketchEditor seems to use the value of geometry after the GeometryChanged event.

 

Am I missing something or is there no way to achieve such an exit condition?

Outcomes