HOW TO
ISnapEnvironment can reference the properties of SnapAgent FeatureSnap objects.
Code:
Dim pUID As UID
Dim pEditor As IEditor
Set pUID = New UID
pUID = "esricore.Editor"
Set pEditor = Application.FindExtensionByCLSID(pUID)
pEditor.StartEditing pWorkspace
Note:
This code example assumes the pWorkspace variable has been defined as an IWorkspace and has been set to a valid workspace.
Code:
Dim pSnapEnvironment As ISnapEnvironment
Dim pFeatureSnapagent As IFeatureSnapAgent
Set pSnapEnvironment = pEditor
Set pFeatureSnapAgent = New FeatureSnap
Set pFeatureSnapAgent.FeatureClass = pFeatureClass
pFeatureSnapAgent.HitType = esriGeometryPartBoundary
pSnapEnvironment.ClearSnapAgents
pSnapEnvironment.AddSnapAgent pFeatureSnapagent
pSnapEnvironment.SnapToleranceUnits = esriSnapTolerancePixels
pSnapEnvironment.SnapTolerance = 5
Note:
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).
Code:
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
pSnapEnvironment.SnapPoint pPoint1
pSnapEnvironment.SnapPoint pPoint2
Code:
Dim pSketchOperation As ISketchOperation
Dim pEditSketch As IEditSketch
pEditor.StartOperation
Set pSketchOperation = New SketchOperation
pSketchOperation.Start pEditor
Set pEditSketch = pEditor
pEditSketch.AddPoint pPoint1, True
pEditSketch.AddPoint pPoint2, True
pEditSketch.FinishSketch
pEnvelope.Expand 1.2, 1.2, True
pSketchOperation.Finish pEnvelope
Note:
This code assumes the pEnvelope was defined as IEnvelope and has the extent of the feature currently selected and being edited.
Article ID:000002754
Get help from ArcGIS experts
Download the Esri Support App