Buffer snap agent


Purpose
This sample demonstrates how to create a snapping agent based on a buffer around the points of the current editable point feature class. In this sample, a snapped vertex of a feature is located no closer than 1000 map units from the point that is closest to the cursor. For electrical datasets, it is common to want to snap primary lines to the boundary of the symbol representing a pole. Use this snapping agent with an appropriate buffer distance (based on the radius of the pole symbol).

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Open and build the solution to register the BufferSnap class in the ESRI Engine Snap Agents component category.
  2. Run the solution.
  3. Start editing.
  4. Zoom in on some point features to a 1:30000 map scale.
  5. Open the Snapping Environment dialog box and turn on the Buffer Snap agent.
  6. Begin adding new features to snap to buffers (1000 map units) around the point features in the specified feature class.

Additional information

The EditingForm Load event sets up the map and snapping environment. The map units are set to meters and the snap tolerance is set to 2000 map units. An IFeatureCache object is used to contain the point features closest to the cursor location. The feature cache is iterated to find the feature from the cache, which when buffered, is nearest to the cursor location. The cursor is then snapped to this location, which is 1000 map units from this feature.

BufferSnapAgent/BufferSnap.cs Class file containing buffer snapping agent.
Application/EditingForm.cs Form file.
Download the C# files
BufferSnapAgent/BufferSnap.vb Class file containing buffer snapping agent.
Application/EditingForm.vb Form file.
Download the VB.NET files

Download the files for all languages




Development licensing Deployment licensing
Engine Developer Kit ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced
Engine