Can't fill the attribute table programmatically

المشرف العام

Administrator
طاقم الإدارة
I've got a shp-file, here is it's attribute table:



It's easy to fill the attribute table of some pFeature programmatically:

For example, "RECNO" Field(3) has a numeric format

Set pNewFeature.Value(3) =2pNewFeature.storeUsually, it works fine, I shouldn't even start the Edit session for this.

The code merges selected features of the first Layer, but when I'm trying to fill the attribute table in this code below (in the end of code), the error "Object reguired" appears.

Dim pMxDocument As IMxDocumentDim pMap As IMapDim pActiveView As IActiveViewDim pFeatureSelection As IFeatureSelectionDim pTopologicalOperator As ITopologicalOperatorDim pEnumGeometry As IEnumGeometryDim pEnumGeometryBind As IEnumGeometryBindDim pEnumFeature As IEnumFeatureDim pFeature As IFeatureDim pNewFeature As IFeatureDim pOutputGeometry As IGeometryDim pUID As New UIDDim pEditor As IEditorDim pFeatureLayer As IFeatureLayerDim pFeatureClass As IFeatureClassSet pMxDocument = ThisDocumentSet pMap = pMxDocument.FocusMapSet pActiveView = pMxDocument.FocusMapSet pFeatureLayer = pMap.Layer(0)Set pFeatureClass = pFeatureLayer.FeatureClass' Get a handle to the Editor extension.pUID = "esriEditor.Editor"Set pEditor = Application.FindExtensionByCLSID(pUID)Set pFeatureSelection = pFeatureLayerSet pEnumGeometryBind = New EnumFeatureGeometrypEnumGeometryBind.BindGeometrySource Nothing, pFeatureSelection.SelectionSet' MsgBox pFeatureSelection.SelectionSet.Count, vbInformation, "Num of Recs"If pFeatureSelection.SelectionSet.Count = 0 Then Exit SubSet pEnumGeometry = pEnumGeometryBindSet pTopologicalOperator = New PolygonpTopologicalOperator.ConstructUnion pEnumGeometry' Get selected set and put into cursor.Set pEnumFeature = pMap.FeatureSelectionSet pFeature = pEnumFeature.Next' Get geometry of each polygon, add it to the new polyon' and delete the original one. Do While Not pFeature Is Nothing If pOutputGeometry Is Nothing Then Set pOutputGeometry = pFeature.Shape Else Set pOutputGeometry = pTopologicalOperator.Union(pFeature.Shape) End If Set pTopologicalOperator = pOutputGeometry pFeature.Delete Set pFeature = pEnumFeature.Next Loop' Create new feature and store the application number.Set pNewFeature = pFeatureClass.CreateFeatureSet pNewFeature.Shape = pOutputGeometry'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'THE PROBLEM IS HERESet pNewFeature.Value(3) = 2' Store new merged feature.pNewFeature.Store' Refresh the map viewpActiveView.Refresh



أكثر...
 
أعلى