burabolin

Insert/Delete Vertex programatically

Discussion created by burabolin on Aug 8, 2011
Latest reply on Aug 9, 2011 by burabolin
I'd like to implement function to insert vertex on polyline just like in arcmap.
When mouse cursor is located on boundary snap on polyline, clicking right mouse button, select insert vertex on popup menu.

My code to insert vetex is something like this.

==============================================
Dim pSelected As IEnumFeature = m_Map.FeatureSelection
Dim pFeature As IFeature = pSelected.Next()
Dim pGeom As IGeometry = pFeature.Shape

......

Dim pGeomColn As IGeometryCollection = pGeom
Dim pPath As IPath = pGeomColn.Geometry(partIndex)
Dim pPoints As IPointCollection = pPath

Dim Missing As Object = Type.Missing
Dim val As Object
If vertexIndex = 0 Then
       val = 1
       pPoints.AddPoint(pHitPoint, val, Missing)
Else
        val = vertexIndex
        pPoints.AddPoint(pHitPoint, Missing, val)
End If

Dim pGeom As IGeometry = pPoints
pFeature.Shape = pGeom
pFeature.Store()
==========================================

At line pFeature.Shape = pGeom
Error occures like below.

"The feature object does not have a valid shaple."

Do I missed something else in code?
Any advice is OK.

Outcomes