Problem Creating Features in ArcObjects

339
2
08-19-2010 12:41 PM
Highlighted
New Contributor II
Hello all.

I've got some code (attached) that intersects a selected parcel with a soils layer, then creates a feature class in a file geodatabase with the requisite data, then adds said feature class to ArcMap for further manual editing.

The feature class gets created OK and gets all the requisite attributes, but is absolutely uneditable. To boot, I notice that the 'shape_area' and 'shape_length' fields are null and am guessing that's a symptom of the underlying problem.

Any ideas?

I've attached the code in its entirety, but here's where I think the problem is:

__________________________________________________ ___________________________________

Dim pWS As IWorkspace = OpenFGDBWorkspace()
Dim pFWs As IFeatureWorkspace = pWS
Dim pNewFC As IFeatureClass = pFWs.OpenFeatureClass("P" & pinNoDash)

Dim newFCSTIndx As Integer = pNewFC.Fields.FindField("SoilType")
Dim newFCAcresIndx As Integer = pNewFC.Fields.FindField("Acreage")
Dim pWSEdit As IWorkspaceEdit = pFWs
Dim pArea As IArea

Dim pFBuf As IFeatureBuffer = pNewFC.CreateFeatureBuffer()
Dim pInsCur As IFeatureCursor = pNewFC.Insert(True)

Dim pG As IGeometry

Try
Do Until parFeat Is Nothing
pGeom = parFeat.ShapeCopy
pSoilsCur = PerformSpatialQuery(pSoilsFC, pGeom, esriSpatialRelEnum.esriSpatialRelIntersects, Nothing)
soilsFeat = pSoilsCur.NextFeature
soiltypeIndx = soilsFeat.Fields.FindField("DSL_NAME")

Do Until soilsFeat Is Nothing

pTopoOp = soilsFeat.ShapeCopy

outPoly = pTopoOp.Intersect(pGeom, esriGeometryDimension.esriGeometry2Dimension)
pG = outPoly

pGeometryColl = outPoly

pArea = outPoly

pFBuf.Shape = pG 'outPoly
pFBuf.Value(newFCSTIndx) = soilsFeat.Value(soiltypeIndx)
pFBuf.Value(newFCAcresIndx) = pArea.Area / 43560

pWSEdit.StartEditing(False)
pWSEdit.StartEditOperation()
pInsCur.InsertFeature(pFBuf)
pWSEdit.StopEditOperation()
pWSEdit.StopEditing(True)

'If pGeometryColl.GeometryCount.ToString Then

'End If

'MsgBox(pNewFeat.OID)

'FlashGeometry(outPoly, aColor, screenDisplay, 1000)
soilsFeat = pSoilsCur.NextFeature

Loop

parFeat = pFCur.NextFeature
Loop
Catch ex As Exception
MsgBox(ex.Message)
Finally
Marshal.ReleaseComObject(pInsCur)
Marshal.ReleaseComObject(pFCur)
End Try

__________________________________________________ ___________________________________

Thanks in advance!
Reply
0 Kudos
2 Replies
Highlighted
Regular Contributor III
Looks like you're using the same feature buffer object over and over inside your loop.  You need to create a new feature buffer each time (within the loop).
Reply
0 Kudos
Highlighted
Occasional Contributor
hi,

  How you sending spatial Objects into featurclass ?, I means Geometry(Point,Line or Polygon...You are just creating Non spatial rows right ? here your missing something...

Thanks and Regards,

Venkat
Reply
0 Kudos