zoukankan      html  css  js  c++  java
  • 成功在C#和VB中将shp转换为CAD

    C#中:
    1、首先,添加一个LicenseControl,如图所示, 。在上面点击右键选择属性,在弹出的属性窗体上选择如下:选中ArcInfo即可,其余都不选。右侧的Extention可选。

    2、然后再在菜单栏上选择“项目”——“Add ArcGIS Reference…”,在弹出的窗体上添加引用ConversionTools,Geoprocessing,Geoprocessor,如下图所示:

    3、在窗体上添加一个按钮,在窗体的代码窗口上输入下列代码:

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    using ESRI.ArcGIS.ConversionTools;

    using ESRI.ArcGIS.Display;

    using ESRI.ArcGIS.esriSystem;

    using ESRI.ArcGIS.Geoprocessor;

    using ESRI.ArcGIS.Geoprocessing;

    using ESRI.ArcGIS.Geometry;

    using ESRI.ArcGIS.Output;

    namespace WindowsApplication1

    {


    public partial class Form1 : Form


    {


    public Form1()


    {


    InitializeComponent();


    }



    private void button1_Click(object sender, EventArgs e)


    {


    Geoprocessor GP = new Geoprocessor();


    ExportCAD GPexport = new ExportCAD();


    GPexport.Output_File = @"F:\XZY\Test\D111.dxf";
    //
    输出的文件名


    GPexport.Output_Type = "DXF_R2000";
    //
    输出的文件类型


    GPexport.in_features = @"F:\XZY\Test\q.shp";
    //
    源文件


    GP.Execute(GPexport, null);


    MessageBox.Show("
    转换完成!");


    }


    }

    }
    本机安装有VS2005ArcInfo 9.2ArcEngine 9.2 for .Net,在本机上测试运行成功!

    VB.Net中:
    第一步和第二步同C#相同,只是代码不同,如下:

    Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


    Dim gp As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()


    Dim pExptoCAD As ExportCAD = New ExportCAD()


    pExptoCAD.in_features = "F:\XZY\Test\q.shp"


    pExptoCAD.Output_File = "F:\XZY\Test\VB1.dwg"


    pExptoCAD.Output_Type = "DWG_R2004"


    gp.Execute(pExptoCAD, Nothing)


    MsgBox("OK!")


    End Sub

    End Class

    值得注意的是:Geoprocessor这个类在ESRI.ArcGIS.Geoprocessor和ESRI.ArcGIS.Geoprocessing中都有,如果不指定的话,在VB.Net中默认为ESRI.ArcGIS.Geoprocessing,将无法实现。在C# 中也是同样的问题,但是在C# 中可以在执行方法的时候人为的指定它的重载函数。
    来自:http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=32692&extra=pageD1&page=1
  • 相关阅读:
    MKMapVIew学习系列2 在地图上绘制出你运行的轨迹
    WPF SDK研究 Intro(6) WordGame1
    WPF SDK研究 Intro(3) QuickStart3
    WPF SDK研究 Layout(1) Grid
    WPF SDK研究 目录 前言
    WPF SDK研究 Intro(7) WordGame2
    WPF SDK研究 Layout(2) GridComplex
    对vs2005创建的WPF模板分析
    WPF SDK研究 Intro(4) QuickStart4
    《Programming WPF》翻译 第6章 资源
  • 原文地址:https://www.cnblogs.com/gisoracle/p/1535978.html
Copyright © 2011-2022 走看看