ArcEngine 入门

    技术2025-08-30  14

    以前总是抱怨arcengine 难学,类库太多,不知道如何下手,到网上也搜不到适合的例子,也不能运行例子。其实Esri为了减少开发者学习成本,做了很多工作,我们所要做的是利用Esri提供的资源。

    装上ArcEngine 之后 在arcgis 的安装目录里有这些资源:

    1    /ArcGIS/DeveloperKit/SamplesNET/Engine   vs 平台下的Engine 的例子

    2   /ArcGIS/DeveloperKit/SamplesNET/data   Engine 例子对应的数据

    3   /DeveloperKit/Diagrams  ArcEngine 的类库文档,非常有用,关键是要看懂它。

    4   /ArcGIS/DeveloperKit/Help  Help 当安装了Engine 和vs之后,打开 vs 的“帮助” -> 如何实现,出现帮助文档。这也是一个很好的入门材料。

     

     

    下面说说 Engine 里面的例子。如果你用vs 打开 有些能运行,有些运行完了没有什么结果。如果是Form 这样的程序,你运行完了会有windows 界面出现,有些程序是生成dll文件的。那么有人会问如何使用dll文件,它有什么作用?据我现在知道,生成按钮,到处使用。

    以Engine 下面的例子 ExportActiveView为例。双击ExportActiveViewCS_Net2005.sln 把项目导入到vs2005 中.

    在 /ExportActiveView/CSharp/ExportActiveViewCS_Net/bin/Debug 目录下 会多出几个文件。

    其中ExportActiveViewCS_Net.dll 是我们最关心的。

    当我们生成这个dll文件时,dll 文件已经注册了。现在 打开arcmap

    点击Tools 菜单->Customize 按钮 。点击Commands选项卡的.点击Developer Samples category 对话框如下

     

     

    点击 Export Active View CS 拖动它到任何合法的工具条中。结果如下

    最右边的工具条中出现了一个像兔子一样的工具按钮。点击它 会产生一张jpg 图片

    运行结果如下:

     

    这样就算明白了 dll 文件的作用了,简单的说就是封装了一个工具按钮。能在arcmap arccatalog 等各种arcgis 产品中使用 和编程中使用。

     

    最后告诉大家 一个很好的例子 把下面的地址输入到 vs的帮助文档 url 中

    ms-help://ESRI.EDNv9.3/NET_Engine/7bd52ed1-18ae-4aa7-8cde-e9eaed9537fe.htm

     

    里面详细介绍了

     

    Loading the ArcGIS Engine controls Embedding the ArcGIS Engine controls in a container License initialization using the LicenseControl Loading map documents into MapControl and PageLayoutControl Setting the ToolbarControl and TOCControl buddy controls Handling form resize Adding commands to the ToolbarControl Creating a pop-up menu for the PageLayoutControl Creating a palette of tools Managing label editing in the TOCControl Drawing shapes on the MapControl Creating a custom tool Customizing the ToolbarControl Saving and loading ToolbarControl items Printing the page layout

     照着它做一遍 ,基本的开发流程就明白了

     

    最新回复(0)