Wednesday, September 10, 2014

Xóa vertex

 Public Sub deletevertex()
            Dim sketchOp As IEngineSketchOperation = New EngineSketchOperationClass()
            Dim engineEditor As IEngineEditor = New EngineEditorClass()
            Dim editSketch As IEngineEditSketch = CType(engineEditor, IEngineEditSketch)
            'Clone the original edit sketch envelope. Used to invalidate the display.
            Dim clonedEnv As IClone = (CType(editSketch.Geometry.Envelope, IClone)).Clone()
            Dim invalidateEnv As IEnvelope = CType(clonedEnv, IEnvelope)

            'Start the edit sketch operation.
            sketchOp.Start(engineEditor)

            'Set the MenuString to identify the edit sketch operation.
            sketchOp.SetMenuString("Delete Vertex")

            'Get the point collection from the edit sketch.
            Dim pointCol As IPointCollection = CType(editSketch.Geometry, IPointCollection)

            'Clone the vertex to be removed.
            Dim vertexToRemove As IClone = CType(pointCol.Point(pointCol.PointCount - 1), IClone)
            vertexToRemove.Clone()


            'Remove the last vertex and refresh the sketch.
            pointCol.RemovePoints(pointCol.PointCount - 1, 1)
            editSketch.Geometry = CType(pointCol, IGeometry)
            editSketch.RefreshSketch()
            'Finish the sketch operation.
            sketchOp.Finish(editSketch.Geometry.Envelope, esriEngineSketchOperationType.esriEngineSketchOperationVertexDeleted, CType(vertexToRemove, System.Object))
        End Sub

No comments:

Post a Comment