The best approach to run a system tool—or any tool or model created, and saved in a toolbox from a button—is to create an add-in control. Add-in controls are a new feature in ArcGIS 10. You can create an add-in control through the Customize dialog box by selecting the Commands tab category, then Add-in Controls. For more information on getting started with add-ins, see Building add-ins for ArcGIS Desktop.
Once created, you can add the control to toolbars or menus. When you click a button (for example, in ArcMap), its OnClick method is called.
To start a geoprocessing tool from the button, copy and paste the following code example inside the code block of the OnClick method. The InvokeModal method of the IGPToolCommandHelper2 interface is called to open the tool. Remember to replace the name of the toolbox, and the name of the tool or script you want to reference. Pay close attention to the tool's actual location and name, not its label. You can get this information by right-clicking the tool in Catalog and reviewing the properties. For more information, see Toolbox properties: name, label, and alias in the ArcGIS Desktop User Help system. 
When you add the control, you can click the button and the Buffer tool appears. See the following code example:

[C#]

protected override void OnClick()
{ //Set a reference to the IGPCommandHelper2 interface.
IGPToolCommandHelper2 pToolHelper = new GPToolCommandHelperClass()as
IGPToolCommandHelper2; //Set the tool you want to invoke.
string toolboxName = @
"<ArcGIS install directory>\ArcToolbox\Toolboxes\Analysis Tools.tbx";
pToolHelper.SetToolByName(toolboxName, "Buffer"); //Create the messages object and a bool to pass to the InvokeModal method.
IGPMessages msgs;
msgs = new GPMessagesClass();
bool pok = true; //Invoke the tool.
pToolHelper.InvokeModal(0, null, out pok, out msgs); } //============================

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using System.Windows.Forms;
using ESRI.ArcGIS.Geodatabase;
//using ESRI.ArcGIS.GeoDatabaseUI;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.ArcMapUI;

using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.DataSourcesRaster;

using ESRI.ArcGIS.Output;
using ESRI.ArcGIS.Display;

using System.IO;
using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.Geoprocessing;
using ESRI.ArcGIS.GeoprocessingUI;

 

private void myinfo()
{
IGPToolCommandHelper2 pToolHelper = new GPToolCommandHelperClass() as
IGPToolCommandHelper2;

//Set the tool you want to invoke.
string toolboxName = @"D:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Analysis Tools.tbx";
pToolHelper.SetToolByName(toolboxName, "Buffer");

//Create the messages object and a bool to pass to the InvokeModal method.
IGPMessages msgs;
msgs = new GPMessagesClass();
bool pok = true;

//Invoke the tool.
pToolHelper.InvokeModal(0, null, out pok, out msgs);
}

 

AE 打开工具箱工具的对话框的更多相关文章

  1. Mac下safari、chrome打开开发者工具快捷键

    mac下safari和chrome打开开发者工具的快捷键相同,都是option(alt)+command+i 这个是我的默认配置,没有更改过的.

  2. MFC中打开选择文件夹对话框,并将选中的文件夹地址显示在编辑框中

    一般用于选择你要将文件保存到那个目录下,此程序还包含新建文件夹功能 BROWSEINFO bi; ZeroMemory(&bi, sizeof(BROWSEINFO));  //指定存放文件的 ...

  3. MAC 打开Chrome打开开发者工具的快捷键

    mac下safari和chrome打开开发者工具的快捷键相同,都是 option(alt)+command+i 这个是我的默认配置,没有更改过的.

  4. 利用C#与AE调用GP工具

    转自原文 利用C#与AE调用GP工具 第一,首先要明确自己需要调用arctoolbox里面的什么工具,实现什么样的功能. 第三,编写command或tool工具,编写自己要的功能工具. 1)首先创建一 ...

  5. 一款批量修改AE模板的工具

    一.需求分析 对于视频后期剪辑及相关从业人员来说,AE(After Effects)模板效果是一个不错的开始点.在模板效果的基础上,可以很快的做出各种炫酷的后期效果.但是在网上下载的模板工程中,往往包 ...

  6. 如何解决-win7系统打开截图工具显示“截图工具当前未在计算机上运行”

    打开win7系统自带截图工具,显示"截图工具当前未在计算机上运行.请重新启动计算机,然后重试",  解决方法  1.首先在C盘中搜索tpcps.dll: 2.将数据最大那个tpcp ...

  7. IE9浏览器打开开发者工具代码正常执行,反之报错

    1.can i use console  IE9开发者工具打开时支持console对象,否则报错. 2.由于出现错误 80020101 而导致此项操作无法完成 测试代码 <!DOCTYPE ht ...

  8. 解决Android studio导航tools下没有android怎么打开DDMS工具

    因为这个功能用的人少, 新版本就去掉菜单入口了, 但这个功能并没有删除,打开方式:点开terminal ,也就是AS自带的命令行工具, 输入monitor 回车就启动了, 1.点开terminal 2 ...

  9. Electron 打开开发者工具 devtools

    转载:http://newsn.com.cn/say/electron-devtools.html 在electron开发的过程中,可以用代码控制打开自带chrome的devtools开发者工具,进而 ...

随机推荐

  1. 连接数据库:ERROR:The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration prop

    本打算在maven项目中配置mybatis试试看,想到mybatis如果不是在容器中运行,那么他的事务控制实际上可以使用的是jdbc的提交和回滚,这就要在pom.xml文件中配置mysql-conne ...

  2. 2.4G无线模块NRF2401

    RF24L01+,是工作在2.4~2.5GHz 频段的,具备自动重发功能,6 个数据传输通道,最大无线传输速率为2Mbits.MCU 可与该芯片通过SPI 接口访问芯片的寄存器进行配置,达到控制模块. ...

  3. fastdfs5.10 centos6.9 安装配置

    下载相关软件 https://codeload.github.com/happyfish100/fastdfs/tar.gz/V5.10http://download.csdn.net/detail/ ...

  4. DotNetOpenAuth实践之Webform资源服务器配置

    系列目录: DotNetOpenAuth实践系列(源码在这里) 上篇我们讲到WebApi资源服务器配置,这篇我们说一下Webform下的ashx,aspx做的接口如何使用OAuth2认证 一.环境搭建 ...

  5. ceph笔记(一)

    一.ceph概述本质上是rados:可靠的.自动的.分布式对象存储特性:高效性(大型的网络raid,性能无限接近raid).统一性(支持文件存储.块存储.对象存储).可扩展性数据库的一个弱点:查表ce ...

  6. css特效-一道闪光在图片上划过

    在百度音乐 http://music.baidu.com/ 看到这么一个图片效果,当鼠标移上去的时候,会有一道闪光在图片上划过,效果挺酷炫的.于是把这个效果再实现一下:大体思想是,设计一个透明层i,s ...

  7. ubuntu怎么连接centos远程桌面

    1.系统软件设置CentOS端:查看是否安装了vnc软件# rpm -q vnc vnc-serverpackage vnc is not installedvnc-server-4.1.2-14.e ...

  8. Linq简单使用

    简单使用 from子查询 关联多个数据源 分组 let 子句 查询对象(上例中为list变量)为IEnumerable<T>或IQueryable<T>类型 查询返回结果同样为 ...

  9. js的循环

    1.for(){} 这种方法可能每个人都用过,不多说. 2.ES5的forEach myArray.forEach(function (value) { console.log(value); }); ...

  10. windows下运行命令行mysql,提示mysql不是内部命令,解决办法

    1. 打开CMD命令行,连接本地mysql数据库:mysql -u root -p 提示‘mysql’不是本地命令,解决办法如下: 找到你安装的mysql的目录,打开当前目录下的bin文件夹,你可以看 ...