AnsweredAssumed Answered

iFeatureCursor - stuck on first shape but not attributes

Question asked by saipo on Oct 30, 2012
Latest reply on Oct 31, 2012 by kenbuja
Hello,


I'm copying a selection of features (points) from one layer to another using ifeaturecursor.
In the source layer the shapes (points) are in their correct location.  After the copy
all the shapes (points) in the second layer sit ontop of each other and not in the same location as the original
shapes.  The attribuites are correct.  I have placed a msgbox to display the x co ordinate of
the points before and after the copy.  They appear to be correct except the shape is not drawn
in the correct location.  Any suggestions

Code below.

            Dim pFlds As IFields
            Dim lSFld As Long
            Dim thedefectcursor As IFeatureCursor 'source features to copy
            Dim thenewfeature As IFeature
            Dim thepointshape as ipoint
            queryFilter.WhereClause = "Line_id = 10001"
            thedefectcursor = defectfeaturelayer.Search(queryFilter, True) ' populate the features to copy
            Dim thepoint As IFeature
            thepoint = thedefectcursor.NextFeature
            Do While Not (thepoint Is Nothing)
  thepointshape = thepoint.Value(thepoint.Fields.FindField("SHAPE"))
  MsgBox(thepointshape.X)
                thenewfeature = tmp_defectslayer.FeatureClass.CreateFeature
                pFlds = thepoint.Fields
                For i = 0 To thepoint.Fields.FieldCount - 1
                    If pFlds.Field(i).Name <> "OBJECTID" Then
                        lSFld = thepoint.Fields.FindField(pFlds.Field(i).Name)
                        thenewfeature.Value(i) = thepoint.Value(lSFld)
                    End If
                Next i
    thepointshape = thenewfeature.Value(thepoint.Fields.FindField("SHAPE"))
                MsgBox(thepointshape.X)
                thenewfeature.Store()
                thepoint = thedefectcursor.NextFeature()
            Loop

Outcomes