|
阅读:1377回复:1
[求助]在AE中怎么把CAD图转化为SHP格式呢?
<P>由于需要,我现在做的东西需要将cad图转化为shp格式。用代码转化。请问有没高手能提供哈源代码呢?我写的部分代码如下:</P>
<P> private void button1_Click(object sender, EventArgs e)<BR> {<BR> OpenFileDialog openFileDialog1 = new OpenFileDialog();<BR> openFileDialog1.Filter = "CAD file(*.DWG)|*.DWG|CAD DGN file(*.DGN)|*.DGN|CAD DXF file(*.DXF)|*.DXF";<BR> string FilePath;<BR> string FileName = string.Empty;<BR> if (openFileDialog1.ShowDialog() == DialogResult.OK)<BR> {<BR> FileName = openFileDialog1.FileName;<BR> }<BR> if (FileName.Length == 0)<BR> {<BR> this.Close();<BR> }<BR> else<BR> {<BR> string strfile = FileName.Substring(FileName.LastIndexOf("\\") + 1);<BR> FilePath = FileName.Substring(0, FileName.Length - strfile.Length - 1);<BR> IWorkspaceFactory pWorkspaceFactory = new CadWorkspaceFactoryClass();<BR> IFeatureWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(FilePath, 0) as IFeatureWorkspace;<BR> IFeatureDataset pFeatureDataset = pWorkspace.OpenFeatureDataset(strfile);<BR> IFeatureClassContainer pFeatureClassContainer = pFeatureDataset as IFeatureClassContainer;<BR> IFeatureClass pFeatureClass;<BR> IFeatureLayer pFeatureLayer;</P> <P> IDataset pDataset;<BR> for (int i = 0; i < pFeatureClassContainer.ClassCount; i++)<BR> {<BR> pFeatureClass = pFeatureClassContainer.get_Class(i);<BR> if (pFeatureClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)<BR> {<BR> pFeatureLayer = new CadAnnotationLayerClass();<BR> }<BR> else<BR> {<BR> pFeatureLayer = new FeatureLayerClass();<BR> }</P> <P> pFeatureLayer.Name = pFeatureClass.AliasName;<BR> pFeatureLayer.FeatureClass = pFeatureClass;</P> <P> axMapControl1.AddLayer(pFeatureLayer, 0);<BR> }<BR> }<BR> }<BR>在axMapControl中能看到图像。现在我要做的就是将格层保存为shp格式。请问我该怎么做呢。或者说有其他方法进行转化呢。望高手指点!</P> |
|
|
1楼#
发布于:2008-07-07 14:55
<P>用IFeatureDataConverter这个接口转</P>
|
|