ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping.Events Namespace / BeforeSketchCompletedEvent Class / Subscribe Method
A delegate that is executed when the BeforeSketchCompletedEvent is published.
(optional) The type of reference used to maintain the delegate. false is a weak reference, true is a strong reference. (default value = false)
Example

In This Topic
    Subscribe Method (BeforeSketchCompletedEvent)
    In This Topic
    Subscribes to the BeforeSketchCompletedEvent that is published before a sketch is completed within certain tools.
    Syntax

    Parameters

    func
    A delegate that is executed when the BeforeSketchCompletedEvent is published.
    keepSubscriberAlive
    (optional) The type of reference used to maintain the delegate. false is a weak reference, true is a strong reference. (default value = false)

    Return Value

    A token that uniquely identifies the added subscription, and may subsequently be used with Unsubscribe.
    Example
    Listen to the before sketch completed event and modify the sketch
    // Occurs before a sketch is completed. BeforeSketchCompleted event is fired by 
    //  - COTS construction tools (except annotation, dimension geometry types), 
    //  - Edit Vertices, Reshape, Align Features
    //  - 3rd party tools with FireSketchEvents = true
    // Register for the BeforeSketchCompleted event
    BeforeSketchCompletedEvent.Subscribe(beforeSketchCompletedEventArgs
      =>
    {
      //assign sketch Z values from default surface and set the sketch geometry
      var modifiedSketch = beforeSketchCompletedEventArgs.MapView.Map.GetZsFromSurfaceAsync(beforeSketchCompletedEventArgs.Sketch).Result;
      beforeSketchCompletedEventArgs.SetSketchGeometry(modifiedSketch.Geometry);
      return Task.CompletedTask;
    });
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also