Dim addPoint as IPoint = pActiveview.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) pEditSketch.AddPoint(addPoint, True)
Public Class ToolEditSketch Inherits ESRI.ArcGIS.Desktop.AddIns.Tool Dim featurelayer As IFeatureLayer Dim featureClass As IFeatureClass Dim feature As IFeature Dim pGeometry As IGeometry5 Dim pActiveview As IActiveView Dim projCoordSys As IProjectedCoordinateSystem5 Dim pEditSketch As IEditSketch3 Dim sketchOp As ISketchOperation2 Public Sub New() End Sub Protected Overrides Sub OnActivate() 'Define Spatial Reference and Coordinate System Dim spatialReferenceFactory As ISpatialReferenceFactory = New SpatialReferenceEnvironment projCoordSys = spatialReferenceFactory.CreateProjectedCoordinateSystem(102718) ' ESRI spatial reference code for Long Island Zone is 102718 'Public Method Call to fill global applicationa and document variables InitializeApplicationVariables() 'Public Method Call to get the target layer and featureclass featurelayer = GetLayer("Sewer Sheet Outlines") featureClass = featurelayer.FeatureClass End Sub Protected Overrides Sub OnMouseDown(ByVal arg As ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs) 'Get the Activeview from the map document pActiveview = pMxDoc.FocusMap 'If statement to Start Edit Session if not already Editing 'set the Edit Sketch properties pEditSketch = editor pEditSketch.GeometryType = esriGeometryType.esriGeometryPolygon pEditSketch.Geometry = New Polygon Dim point1 As IPoint = New ESRI.ArcGIS.Geometry.Point point1 = pActiveview.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) pEditSketch.AddPoint(point1, False) End Sub Protected Overrides Sub OnDoubleClick() pGeometry = pEditSketch.Geometry feature = featureClass.CreateFeature() feature.Shape = pGeometry feature.Store() ModuleGdBFunctions.EndEditSession() pActiveview = pMxDoc.FocusMap pActiveview.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewAll, Nothing, Nothing) End Sub Protected Overrides Sub OnUpdate() End Sub End Class