This document is archived and information here might be outdated.  Recommended version.


Customizing the editor framework using add-ins (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Editing data > ArcGIS for Desktop editing for developers > Customizing the editor framework using add-ins (ArcObjects .NET 10.6 SDK)

Customizing the editor framework using add-ins


Summary
This topic describes the types of editing customizations—and their respective deployment options—you can create using add-ins.

In this topic


Editor customizations and deployment options

The editing framework can be customized to add your own commands, tools, tasks, extensions, shape constructors, and object inspectors. For an overview of these customizations, see ArcGIS for Desktop editing for developers.
Many of these customizations can be built and deployed as add-ins, while others require development of custom components. For more information on customizing using add-ins, see Building add-ins for ArcGIS Desktop. For information on how to create editor customizations using components, see Editor framework customizations. For general information on components, see Extending ArcObjects.
Developing and deploying your customizations as add-ins is the preferred method.
The following table shows the various editor customization types and their supported customization methods:
Customization type
Add-in
Component
Commands
Yes
Yes
  • Context menus
Yes
Yes
Tools
Yes
Yes
  • Construction tools
Yes
Yes
Extensions
Yes
Yes
Shape constructors
No
Yes
Tasks
No
Yes
Object inspectors
No
Yes
Snap agents
No
Yes
Edit sketch extensions
No
Yes

Creating an editor command add-in

Creating an editor command add-in follows the same workflow as creating a regular ArcGIS command add-in. A reference to the editor is obtained in the add-in constructor. To enable the command while editing, set the Enabled property in the OnUpdate method. See the following code example:
[C#]
public class EditCommand: ESRI.ArcGIS.Desktop.AddIns.Button private IEditor3
    m_Editor;

public EditCommand()
{
    //Get the editor extension.
    UID uID=new UIDClass();
    uID.Value="esriEditor.Editor";
    m_Editor=ArcMap.Application.FindExtensionByCLSID(uID)as IEditor3;
}

protected override void OnUpdate()
{
    Enabled=(m_Editor.EditState == esriEditState.esriStateEditing);
}
[VB.NET]
Public Class Button1
    Inherits ESRI.ArcGIS.Desktop.AddIns.Button
    Dim m_Editor As IEditor3
    
    Public Sub New()
        'Get the editor extension.
        Dim editorUID As UID
        editorUID=New UID
        editorUID.Value="esriEditor.Editor"
        m_Editor=(My.ArcMap.Application.FindExtensionByCLSID(editorUID))
    End Sub
    
    Protected Overrides Sub OnUpdate()
    Enabled=(m_Editor.EditState=esriEditState.esriStateEditing)
End Sub
The Curve conversion add-in is an example of an editor command add-in.

Tools

Editor tools are created to interact with the display. They can be divided into two main types, those that use the shape constructors (straight, arc, trace, right angle, and so on) to provide geometry via the sketch and those that provide their own geometry (via tool events). Both types can be further subdivided into two other subtypes, construction tools and non-construction tools. Construction tools are used to create new features and are found within the construction tools pane in the Create Features window. The polygon, polyline and rectangle tools are examples of construction tools whereas the split polygons tool is an example of regular or non-construction edit tool. It is important to understand what type of tool you want to create as this determines how you go about creating it.

Creating an edit tool that uses shape constructors

To build a tool that uses the shape constructors, you must create a tool add-in that implements ISketchTool, and IShapeConstructorTool. Your custom tool forwards its mouse events (such as mouse move and mouse down) to the current shape constructor, which internally calls the editor's sketch tool. Your tool must also listen to the IEditEvents.OnSketchFinished event so you can obtain the edit sketch geometry (IEditSketch.Geometry) when you finish sketching and perform an edit operation.
If your tool is used to create new features, you should also make it a construction tool so that it appears in the construction tools pane within the Create Features window. To make your tool a construction tool, register it in a construction tool component category for the type of geometry you want to create. For example, if your tool creates polylines, register it in the polyline feature construction tools category.
To create the tool using the Visual Studio wizard, follow the steps for Creating a custom button and tool in the topic, Building custom UI elements using add-ins until Step 4. At Step 4, choose Construction tool as the add-in type and complete the rest of the information. If the tool is to be a construction tool, select the appropriate category.
The resulting .NET class contains the code to create the add-in using the shape constructors. Modify the existing code as required for your tool. You can obtain the sketch geometry in the OnSketchFinished event from the m_edSketch.Geometry property.

Creating an edit tool that does not use shape constructors

If your tool provides its own geometry, that is, will not use the shape constructors, you can build a regular add-in tool to use with the editor. For information on how to build a tool add-in, see the previously mentioned topic, Building custom UI elements using add-ins. As with command add-ins, you'll have to put the editor initialization in the tool add-in constructor and check for the edit state in the OnUpdate method. You need to add code to the tool's mouse events to create your geometry to complete the tool's operation.
If your tool is used to create new features, make it a construction tool so that it appears in the construction tools pane within the Create Features window. To make your tool a construction tool, register it in a construction tool component category for the type of geometry you want to create.
To create the tool using the Visual Studio wizard, follow the steps for Creating a custom button and tool in the previously mentioned topic, Building custom UI elements using add-ins until Step 4. At Step 4, choose Construction tool as the add-in type, uncheck Shape Constructors and complete the rest of the information. If the tool is to be a construction tool, select the appropriate category.

Creating an editor extension add-in

For information on using add-ins to create editor extensions, see Building editor extensions using add-ins.


See Also:

ArcGIS Desktop editing for developers
Editor framework customizations
Building custom UI elements using add-ins




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):

Development licensing Deployment licensing
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Basic ArcGIS Desktop Basic