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. ireport报表制作, 当一个字段显示的数据太多时(数据过长),则需要自动换行

    1.当一个字段显示的数据太长,一个表格放不下,则需要自动换行,选中要更改的表格(要显示动态内容的字段),设置属性Stretch with overflow 为钩选状态. 未勾选之前: 勾选之后: 2. ...

  2. 在delphi原有控件基础上画图

    var C:TControlCanvas; begin C := TControlCanvas.Create; C.Pen.Color := clRed; C.Pen.Width := ; C.Con ...

  3. 字符串匹配的KMP算法(如何实现还需静下心来细看)

    第一部分:KMP算法的理解(转:http://kb.cnblogs.com/page/176818/) 字符串匹配是计算机的基本任务之一. 举例来说,有一个字符串"BBC ABCDAB AB ...

  4. 开始学习MaxCompute

    https://help.aliyun.com/document_detail/34615.html?spm=a2c4g.11186623.6.688.jVxTMW

  5. TeX Live & TeXstudio 安装手记

    数据库课上又看到了那位用 beamer 做 slides 的师兄,想到自己一拖再拖的LaTeX入门,决定赶快动手装个环境再说~在经过一番搜索和研究之后决定先在 windows 底下试用,选择 TeX ...

  6. git用法大全

    转载自实验楼,之前有更新过两篇git的文章,毕竟内容太少,而git还有很多更丰富的技能,在实验楼上有一系列全的教程,这里做一下备案.需要时查阅. Git 实战教程 目录 一.实验说明 二.git的初始 ...

  7. lr_start_transaction/lr_end_transaction事物组合

    lr_start_transaction/lr_end_transaction事物组合 总结一下: lr_start_transaction与lr_end_transaction 为使用最多的事物创造 ...

  8. 用memcached实现的php锁机制

    <?php /** * 使用Memcache实现给进程加锁的类 * * Copyright (C) 2013 JeffJing * * 一些时候需要让系统的某些操作串行化,这个时候就要对这些操作 ...

  9. 百度地图API详解之自定义地图类型

    http://blog.csdn.net/sup_heaven/article/details/8461586 今天的文章主要介绍如何利用地图API实现自定义地图. 百度地图API目前默认支持两种地图 ...

  10. 洛谷P3919 【模板】可持久化数组 [主席树]

    题目传送门 可持久化数组 题目描述 如题,你需要维护这样的一个长度为 $N$ 的数组,支持如下几种操作 在某个历史版本上修改某一个位置上的值 访问某个历史版本上的某一位置的值 此外,每进行一次操作(对 ...