The feature is deleted runtime error - IFeatureEdit.Split

03-08-2011 07:20 AM
New Contributor

I am using the IFeatureEdit.Split tool to split a polyline at several points.  Once the script has looped through all of the point features I start a new loop which loops through all of the polyline features to get table field information.  The problem is when I get to a polyline ID that was previously split an error appears telling me that the feature has been deleted.  I am not sure how to proceed, I think I need to update the feature and attribute table but have been un-successful.  If anyone has any ideas please help.  Code snippet below:

Do Until pFeat1 Is Nothing
    Set pPoint = pFeat1.Shape

    Set pFeatureIndex = New FeatureIndex
    Set pFeatureIndex.FeatureClass = pFClass
    Set pIndexQry = pFeatureIndex
    pFeatureIndex.Index Nothing, Nothing

    pIndexQry.NearestFeature pPoint, lFID, dDis
    qryfilter.WhereClause = "FID = " & lFID
    Set pFCur = pFClass.Search(qryfilter, False)
    Set pFeat = pFCur.NextFeature
    Set ppolyline = pFeat.Shape
    ppolyline.QueryPointAndDistance esriNoExtension, pPoint, False, pCbRdPnt, Loc, dist, False
    If (ppolyline.FromPoint.x = pCbRdPnt.x And ppolyline.FromPoint.y = pCbRdPnt.y) Then
        'do nothing
    ElseIf (ppolyline.ToPoint.x = pCbRdPnt.x And ppolyline.ToPoint.y = pCbRdPnt.y) Then
        'do nothing
        Dim pFeatureEdit As IFeatureEdit
        Set pFeatureEdit = pFeat
        pFeatureEdit.Split pCbRdPnt
    End If
    Set pFeat1 = pFCur1.NextFeature

Do Until pFeat Is Nothing
    Set pCurve = pFeat.Shape

    Ln = pCurve.Length
    ID = pFeat.oid
    cfcc1 = pFeat.Value(pFeat.Fields.FindField("CFCC")) 'This is where the error occurs when it is trying to look for a value of a feature OID that has been deleted.  I don't know how to update the table remove deleted features.
0 Kudos
0 Replies