ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping.Events Namespace / SketchModifiedEvent Class / Subscribe Method
A delegate that is executed when the SketchModifiedEvent 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 (SketchModifiedEvent)
    In This Topic
    Subscribes to the SketchModifiedEvent that is published when a sketch is modified within certain tools.
    Syntax

    Parameters

    action
    A delegate that is executed when the SketchModifiedEvent 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 sketch modified event
    // Occurs when a sketch is modified. SketchModified event is fired by 
    //  - COTS construction tools (except annotation, dimension geometry types), 
    //  - Edit Vertices, Reshape, Align Features
    //  - 3rd party tools with FireSketchEvents = true
    // Handles the SketchModified event, providing access to the current and previous sketch geometries when a sketch
    // is modified.
    // Register for the SketchModified event
    SketchModifiedEvent.Subscribe(sketchModifiedEventArgs
      =>
    {
      // if not an undo operation
      if (!sketchModifiedEventArgs.IsUndo)
      {
        // what was the sketch before the change?
        var prevSketch = sketchModifiedEventArgs.PreviousSketch;
        // what is the current sketch?
        var currentSketch = sketchModifiedEventArgs.CurrentSketch;
        if (currentSketch is Polyline polyline)
        {
          // Examine the current (last) vertex in the line sketch
          var lastSketchPoint = polyline.Points.Last();
          // do something with the last point
        }
      }
    });
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also