This sample turns on the Edit Sketch snap agents and updates the snapping dialog window.
How to use
- Load one or more feature layers into an ArcMap session and Start Editing.
- Paste the code into VBA and run the subroutine.
Public Sub AddSketchSnapAgents()
Dim pEditor As IEditor
Dim pSnapPerpendicular As ISnapAgent
Dim pSnapSketchEdge As ISnapAgent
Dim pSnapSketchVertex As ISnapAgent
Dim pSnapEnvironment As ISnapEnvironment
Dim pID As New UID
Dim pSnapWindow As ISnappingWindow
pID = "esriEditor.Editor"
Set pEditor = Application.FindExtensionByCLSID(pID)
Set pSnapEnvironment = pEditor
'turn on each of the sketch snap agents
Set pSnapPerpendicular = CreateObject("esriEditor.PerpendicularSnap")
pSnapEnvironment.AddSnapAgent pSnapPerpendicular
Set pSnapSketchEdge = CreateObject("esriEditor.SketchSnap")
pSnapEnvironment.AddSnapAgent pSnapSketchEdge
Set pSnapSketchVertex = CreateObject("esriEditor.AnchorSnap")
pSnapEnvironment.AddSnapAgent pSnapSketchVertex
'get the snapping window and refresh it
pID = "esriEditor.SnappingWindow"
Set pSnapWindow = pEditor.FindExtension(pID)
If pSnapWindow Is Nothing Then Exit Sub
pSnapWindow.RefreshContents
End Sub