zoukankan      html  css  js  c++  java
  • AE 打开工具箱工具的对话框

    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>ArcToolboxToolboxesAnalysis 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)ArcGISDesktop10.0ArcToolboxToolboxesAnalysis 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);
    }

     
  • 相关阅读:
    细说 webpack 之流程篇
    git 撤销commit
    Git远程操作详解
    git Could not read from remote repository 解决
    Mysql 关键字及保留字
    使用 Intellij Idea 导出JavaDoc
    【树莓派】盒子常见问题处理基础帮助
    【树莓派】crontab设置Linux设备定时重启
    【医疗行业】关于dcm4che DICOM Toolkit:C-Move与C-Get
    关于操作系统:eos、deepin
  • 原文地址:https://www.cnblogs.com/gisoracle/p/6679723.html
Copyright © 2011-2022 走看看