ISnapEnvironment can reference the properties of SnapAgent FeatureSnap objects.
Dim pUID As UID
Dim pEditor As IEditor
Set pUID = New UID
pUID = "esricore.Editor"
Set pEditor = Application.FindExtensionByCLSID(pUID)
This code example assumes the pWorkspace variable has been defined as an IWorkspace and has been set to a valid workspace.
Dim pSnapEnvironment As ISnapEnvironment
Dim pFeatureSnapagent As IFeatureSnapAgent
Set pSnapEnvironment = pEditor
Set pFeatureSnapAgent = New FeatureSnap
Set pFeatureSnapAgent.FeatureClass = pFeatureClass
pFeatureSnapAgent.HitType = esriGeometryPartBoundary
pSnapEnvironment.SnapToleranceUnits = esriSnapTolerancePixels
pSnapEnvironment.SnapTolerance = 5
This code example assumes the pFeatureClass variable has been defined as an IFeatureClass and has been set to a feature class with edges (such as polygons).
Dim pPoint1 As IPoint
Dim pPoint2 As IPoint
Set pPoint1 = New Point
Set pPoint2 = New Point
pPoint1.X = 413188.31
pPoint1.Y = 1124061.78
pPoint2.X = 438944.57
pPoint2.Y = 1123086.17
Dim pSketchOperation As ISketchOperation
Dim pEditSketch As IEditSketch
Set pSketchOperation = New SketchOperation
Set pEditSketch = pEditor
pEditSketch.AddPoint pPoint1, True
pEditSketch.AddPoint pPoint2, True
pEnvelope.Expand 1.2, 1.2, True
This code assumes the pEnvelope was defined as IEnvelope and has the extent of the feature currently selected and being edited.
Get help from ArcGIS experts
Download the Esri Support App