HOW TO

Listen to multiple vertex events in an edit sketch

Last Published: April 25, 2020

Summary

The ArcObjects SDK provides three methods to listen to changes in edit sketch geometry via the IEditEvents2 interface:

• OnVertexAdded
• OnVertexDeleted
• OnVertexMoved

These events are fired whenever a single vertex is modified on the edit sketch; this allows developers to respond to changes in the edit sketch geometry.

Users can select and modify multiple vertices on the edit sketch in one operation. For example, users can drag a box around multiple vertices and move them, or they can move a segment on a sketch to a new location, which inherently moves two vertices. The API, however, does not fire the existing vertex methods if more than one vertex is being modified at a time.

The instructions provided describe how to listen to these multiple vertex events using the API and the sample code provided.

Procedure

This solution includes a helper class that listens to OnSketchModified internally. This help class compares the sketch geometry before and after modification to determine how the sketch was modified. The class exposes new versions of vertex and sketch events that the developer subscribes to rather than those on the editor.

This class has been included in a Visual Studio 2010 project that can be downloaded and reviewed from ArcGIS.com at Multiple Vertex Events Sample

The new events on this class include:

  • SketchModifiedBegin – Fired when the editor OnSketchModified is fired. Sketch modifications occur between this event and SketchModifiedEnd on this class. This enables developers to determine how many modifications are performed, such as moving a single vertex versus moving a segment that will move two vertices.
  • VertexAdded – Fired when adding a vertex to the sketch. Point, segment part, and vertex index are returned.
  • VertexMoved – Fired when a vertex is moved. This is fired once for each vertex that is moved in an operation. Point, segment part, and vertex index are returned.
  • VertexDeleted – Fired when a vertex is deleted. Point, segment part, and vertex index are returned.
  • SegmentModified – Fired when a segment is modified.
  • SketchCleared – Fired when the sketch is cleared (deleted). This also fires when the sketch is finished.
  • SketchModifiedComplex – Fired when multiple types of vertex operations occur in a sketch modification, such as a vertex is moved while another one is deleted. This usually only occurs programmatically.
  • SketchModifiedEnd – Fired at the end of a sketch modification.

Article ID:000011330

Software:
  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic