ArcEngine开发,向要素类中添加要素的问题
向已存在的要素类中添加要素。几何类型是多边形。在添加几何图形时报错,显示“这个集合中找不到此项目”。
IFeatureClass m_JSYDFc = (m_DesWks as IFeatureWorkspace).OpenFeatureClass(ModData.m_JSYDFcName);
IFields pFS = m_JSYDFc.Fields;
IFieldsEdit pFsE = pFS as IFieldsEdit;
IField pFiled = pFS.get_Field(1);
IFieldEdit pFieldEdit = pFiled as IFieldEdit;
IGeometryDef pGeometryDef = pFieldEdit.GeometryDef;
IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;
pGeometryDefEdit.HasZ_2 = true;
public static void MyInsertFeature(IFeatureClass pFeatureClass, IGeometry pGeometry)
{
IFeatureBuffer pFeaBuffer = pFeaCls.CreateFeatureBuffer();
IFeatureCursor pFeaCursor = pFeaCls.Insert(true);
ITopologicalOperator2 pTopo = pGeometry as ITopologicalOperator2;
pTopo.IsKnownSimple_2 = false;
pTopo.Simplify();
IGeometry pG = pTopo as IGeometry;
pFeaBuffer.Shape = pG;///这里出错,显示“这个集合中找不到此项目”
}
几何类型是多边形。