ArcGIS SDK  

Extending ArcObjects

About Edit Tasks

Edit tasks are very similar to edit commands with one major difference: edit tasks perform a specific operation using a geometry—a geometry typically created by the sketch tools. For example, the Create New Feature edit task creates new features based on the geometry created by the various sketch tools. Similarly, the Select Features Using a Line edit task selects features in the map that are intersected by the edit sketch. In both cases, a geometry created by the sketch tools is used to complete an operation.

Unlike a command or tool, edit tasks are not called directly by a user; instead, the Editor objects calls the currently active edit task (IEditor::CurrentTask). The Editor calls the task's IEditTask::OnFinishSketch member—whenever an edit sketch is completed. At this point, the current edit task assumes control and performs an operation typically involving the geometry cached in the IEditSketch::Geometry property.

An edit task performs an operation generally using a geometry created by the sketch tools; the task is activated by the Editor, not by user interaction.

Having the edit sketch geometry creation and management abstracted away from the edit tasks allows the sketch tools to be reused with any number of edit tasks; however, edit tasks can indirectly exhibit some control on the sketch tools. The current edit task sets the geometry type of the edit sketch—for example, polygon, polyline, multipoint, or point—and this ultimately affects whether the sketch tools are enabled. For example, the Create New Feature task determines the geometry type of the target layer (esriGeometryType::esriGeometryPolygon) and sets the edit sketch geometry type to the same type. If an edit tasks enabled conditions are not met, it can set the edit sketch geometry type to esriGeometryType::esriGeometryNull, which indicates to all the sketch tools that they should not be enabled. For example, the Reshape Feature edit task indirectly disables the sketch tools whenever the feature selection count does not equal one.

The current edit task can affect the status of the sketch tools.

Most edit tasks listen to events fired by the Editor object to maintain the edit session. For example, most tasks listen to the OnCurrentLayerChanged event to control the edit sketch geometry type including setting it to null to disable the sketch tools. A few tasks respond to OnSketchModified to automatically complete an edit sketch when a certain set of criteria has been met. Finally, a few listen for OnCurrentLayerChanged to delete the edit sketch in case the new target layer is incompatible with the current geometry type.

Deciding whether a custom edit task is the solution to your editing problem usually boils down to whether or not an input geometry is necessary to complete a desired editing operation. The geometry does not have to be one created using the sketch tools; the geometry could come from almost anywhere, such as a selected feature. The Modify Feature task is an example of this.

A custom edit task may be a suitable solution if you need to use a geometry to complete the desired editing operation.

All edit tasks must be registered in the ESRI Edit Tasks component category. By default, custom edit tasks appear under the 'Other Tasks' group; you can use the editor options dialog box to better organize them.

For an example of an edit task that creates a new point feature based on the existing sketch geometry, see the ConstructPoint Edit Task Example. Other examples of edit tasks you may want to create include:


Back to top

See Also Extending the Editing Framework and ConstructPoint Edit Task Example.