|
阅读:1465回复:2
[求助]arcgis画点IWorkspaceEdit问题
<P>c#与AE9.2</P>
<P>public void AddPointByStore(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)<BR> {<BR> //得到要添加地物的图层 <BR> IFeatureLayer pFeatureLayer = this.GetPolylineFeatureLayer();<BR> IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;<BR> //定义一个地物类,把要编辑的图层转化为定义的地物类 <BR> //先定义一个编辑的工作空间,然后把转化为数据集,最后转化为编辑工作空间, <BR> IDataset pDataset = pFeatureClass as IDataset;</P> <P> IWorkspaceEdit pWorkspaceEdit = pDataset.Workspace as ESRI.ArcGIS.Geodatabase.IWorkspaceEdit;<BR> IFeature pFeature;<BR> IPoint pPoint;<BR> //开始事务操作 <BR> pWorkspaceEdit.StartEditing(false);<BR> //开始编辑 <BR> pWorkspaceEdit.StartEditOperation();</P> <P> //创建一个地物 <BR> pFeature = pFeatureClass.CreateFeature();<BR> pPoint = new PointClass();<BR> //设置点的坐标 <BR> pPoint.PutCoords(e.x, e.y);<BR> //确定图形类型 <BR> pFeature.Shape = pPoint;<BR> //保存地物 <BR> pFeature.Store();</P> <P> //结束编辑 <BR> pWorkspaceEdit.StopEditOperation();<BR> //结束事务操作 <BR> pWorkspaceEdit.StopEditing(true);<BR> }<BR></P> <P>private IFeatureLayer GetPolylineFeatureLayer()<BR> {<BR> IFeatureLayer pFeatureLayer = this.axmc_Main.Map.get_Layer(0) as IFeatureLayer;<BR> for (int i = 0; i < this.axmc_Main.Map.LayerCount; i++)<BR> {<BR> pFeatureLayer = this.axmc_Main.Map.get_Layer(i) as IFeatureLayer;<BR> if (pFeatureLayer.Name == "Polyline")<BR> break;<BR> }<BR> return pFeatureLayer;<BR> }</P> <P>为什么 每次运行到代码:</P> <P> IWorkspaceEdit pWorkspaceEdit = pDataset.Workspace as ESRI.ArcGIS.Geodatabase.IWorkspaceEdit;<BR>的时候pWorkspaceEdit 的值都是 NULL啊~~~</P> <P>我打开的是 AutoCAD2004格式的dxf文件</P> |
|
|
1楼#
发布于:2008-08-17 23:22
你的编辑图层是线,而你的方法又是点?
|
|
|
|
2楼#
发布于:2008-08-18 09:41
<DIV class=quote><B>以下是引用<I>cl991036</I>在2008-8-17 23:22:00的发言:</B><BR>你的编辑图层是线,而你的方法又是点?</DIV>
<P> <P>即使 我换成 如下 代码 也是出现同样的问题的</P> <P>if (pFeatureLayer.Name == "Point")</P> |
|