ARCEngine 添加创建线要素
添加线
添加线的方法跟添加点一样,不同的只是地物类型不一样而已,我把代码贴出来,大家跟添加点的方式进行对比。这样便于记忆。也有利于理解。
public void AddLineByWrite()
{
IFeatureLayer l = MapCtr.Map.get_Layer(0) as IFeatureLayer;
IFeatureClass fc = l.FeatureClass ;
IFeatureClassWrite fr = fc as IFeatureClassWrite ;
IWorkspaceEdit w = (fc as IDataset).Workspace as IWorkspaceEdit;
IFeature f ;
//可选参数的设置
object Missing = Type.Missing;
IPoint p=new PointClass();
w.StartEditing (true);
w.StartEditOperation() ;
for (int i = 0 ; i< 100 ; i++ )
{
f = fc.CreateFeature();
//定义一个多义线对象
IPolyline PlyLine=new PolylineClass();
//定义一个点的集合
IPointCollection ptclo = PlyLine as IPointCollection;
//定义一系列要添加到多义线上的点对象,并赋初始值
for(int j=0;j<4;j++)
{
p.PutCoords(j,j);
ptclo.AddPoint(p,ref Missing,ref Missing);
}
f.Shape = PlyLine;
fr.WriteFeature (f);
}
w.StopEditOperation();
w.StopEditing(true);
}
至于添加线的其他两种方法,通过修改添加点的代码,就可以得到。可以自己想想然后测试,这样便于记忆和理解。
转载自:https://blog.csdn.net/u013084746/article/details/77971613