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. Effective C++笔记(六):继承与面向对象设计

    参考:http://www.cnblogs.com/ronny/p/3756494.html 条款32:确定你的public继承塑模出is-a关系 “public继承”意味着is-a.适用于base ...

  2. CRM 业务

    1. 创建CRM项目 引入插件 创建数据库 from django.db import models from django.db import models class Department(mod ...

  3. LightOJ 1369 Answering Queries(找规律)

    题目链接:https://vjudge.net/contest/28079#problem/P 题目大意:给你数组A[]以及如下所示的函数f: long long f( int A[], int n  ...

  4. hdu 1850(尼姆博弈)

    Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32 ...

  5. 【PAT】1001. A+B Format (20)

    1001. A+B Format (20) Calculate a + b and output the sum in standard format -- that is, the digits m ...

  6. Templated Helper Methods(二)

      1.Label and Display Elements   2.Whole-Model Templated Helpers     3.Using Metadata to Control Edi ...

  7. java 获取路径的各种方法

    (1).request.getRealPath("/");//不推荐使用获取工程的根路径 (2).request.getRealPath(request.getRequestURI ...

  8. 四 Python基础

    Python是一种计算机编程语言.计算机编程语言和我们日常使用的自然语言有所不同,最大的区别就是,自然语言在不同的语境下有不同的理解,而计算机要根据编程语言执行任务,就必须保证编程语言写出的程序决不能 ...

  9. Join 与 CountDownLatch 之间的区别

    Join 与 CountDownLatch 之间的区别 import java.util.concurrent.CountDownLatch; public class CountDownLatchT ...

  10. 【SQL Server】书签

    书签是什么 不论表是堆结构还是段结构,可以确定的是,表中每一行都是某一页的第N行,这个某一页又是某个数据库文件的第N页,这个某个数据库文件又是构成数据 库的文件组的第N个文件,因此,数据库中的每一行, ...