In this section:
Although macros don't truly extend the editor model (or ArcObjects for that matter), they are worth discussing because they are commonly used to add new editing functionality to a map document quickly.
Macros are perfect for problems that don't require much coding. However, they can still be quite complex, UIControls are macro-based and can nearly mimic a custom command or tool, but they have some drawbacks. They are hard to share with others or even between different map documents, and the code is viewable. You may want to convert your macros to commands or tools if you need to share them or if you use them with multiple map documents. Ease of debugging is a macro's biggest benefit; many commands and tools start off as macros simply because macros are so much easier to debug.
When digitizing on top of an aerial photograph, it is hard to see the edit sketch; it would be better if the edit sketch vertices and segments were larger and perhaps had a different color. Since the editing environment does not persist the sketch symbology, writing a macro is a perfect solution.
This is not a complicated scenarioand one reason why a macro solution may be appropriate. Below is a macro that modifies the edit sketch properties.
Public SubChangeSketchSymbol()DimpEditorAsIEditorDimpEditPropertiesAsIEditPropertiesDimpLineSymbolAsILineSymbolDimpMarkerSymbolAsISimpleMarkerSymbolDimpRgbColorAsIRgbColorDimpIDAs NewUID' Get a reference to the Editor objectpID = "esriEditor.Editor"SetpEditor = Application.FindExtensionByCLSID(pID)SetpEditProperties = pEditor' Query Interface'Change the vertex size and colorSetpMarkerSymbol =NewSimpleMarkerSymbolSetpRgbColor =NewRgbColor pRgbColor.Blue = 255 pMarkerSymbol.Color = pRgbColor pMarkerSymbol.Size = 6SetpEditProperties.SketchVertexSymbol = pMarkerSymbol' Change the sketch symbol to use a red lineSetpLineSymbol =NewSimpleLineSymbolSetpRgbColor =NewRgbColor pRgbColor.Red = 255 pLineSymbol.Color = pRgbColorSetpEditProperties.SketchSymbol = pLineSymbolEnd Sub
Instead of having the color hardcoded, try enhancing the macro to use a color dialog box picker.
Another useful macro is one that applies global changes to attributes; for example, a macro that changes the case of records stored in a text property. However, macros aren't only used for simple, one-function routines; almost any command or tool can be written as a macro in VBA.
Edit tasks are similar to edit commands with one major difference: edit tasks perform a specific operation using a geometry, typically one which was created by a sketch tool. 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.
Snap agents facilitate geometry placement. For example, the sketch tools make use of snap agents to enable a user to precisely place an edit sketch vertex. Because snap agents are so widely used, the editing framework manages a snapping environmenta collection of snap agents and a snap tolerance (ISnapEnvironment::SnapTolerance).
It would be easy to say that editor extensions extend the editing framework, and although this is true, so do custom commands, tools, edit tasks, and so on. Editor extensions are just another way developers can plug in to the editing model and extend it. The difference between editor extensions and other customizations is that extensions are automatically loaded and unloaded by the application; there is only ever one instance of an extension running at a time.
See Also Extending the Editing Framework.