ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Mapping.Events Namespace / BeforeSketchCompletedEventArgs Class / SetSketchGeometry Method
The new sketch geometry.
Example

In This Topic
    SetSketchGeometry Method
    In This Topic
    Sets the current geometry of the sketch without finishing it.
    Syntax
    public void SetSketchGeometry( 
       Geometry newSketch
    )
    Public Sub SetSketchGeometry( _
       ByVal newSketch As Geometry _
    ) 

    Parameters

    newSketch
    The new sketch geometry.
    Remarks
    if the sketch geometry type of newSketch is different than the sketch geometry type of Sketch the newSketch will be ignored and the Sketch geometry will be used by the tool.
    Example
    Listen to the before sketch completed event and modify the sketch
    // BeforeSketchCompleted event is fired by 
    //  - COTS construction tools (except annotation, dimension geometry types), 
    //  - Edit Vertices, Reshape, Align Features
    //  - 3rd party tools with FireSketchEvents = true
    
    
    //Subscribe to the before sketch completed event
    //ArcGIS.Desktop.Mapping.Events.BeforeSketchCompletedEvent.Subscribe(OnBeforeSketchCompleted);
    
    private Task OnBeforeSketchCompleted(BeforeSketchCompletedEventArgs args)
    {
      //assign sketch Z values from default surface and set the sketch geometry
      var modifiedSketch = args.MapView.Map.GetZsFromSurfaceAsync(args.Sketch).Result;
      args.SetSketchGeometry(modifiedSketch.Geometry);
      return Task.CompletedTask;
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also