public static void MyInsertFeature(IFeatureClass pFeatureClass, IGeometry pGeometry)
{
IFeatureBuffer pFeatureBuffer=null;
int typeFieldIndex = pFeatureClass.FindField("Layer");
pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();
IFeatureCursor insertCursor = pFeatureClass.Insert(true);
pFeatureBuffer.set_Value(typeFieldIndex, "ZBTZ");
pFeatureBuffer.Shape = pGeometry;
insertCursor.InsertFeature(pFeatureBuffer);
}
程序調試時,每次到 pFeatureBuffer.Shape = pGeometry;這裡就報錯“這個集合中找不到此項目。”,pGeometry明明不是null啊.求高手解答啊。困擾好久了。很郁悶。
找到原因了!!!原來是數據類型不匹配,所以不能賦值。
在featureclass定義的時候應該加上geometryDefEdit.HasZ_2 = true;
不然無法將3d數據強行賦給2d的