Blog

Run ArcTool using ArcObject

Posted by Yogesh Sharma Blogs | ArcObject Dec 03, 2012
Run ArcTool using ArcObject.
RUN ARCTOOL USING ARCOBJECT.

public override void OnClick()
{
    UID puid = new UIDClass();
    puid.Value = "esriGeoprocessingUI.ArcToolboxExtension";

    IArcToolboxExtension pArcToolboxExt;

    pArcToolboxExt = (IArcToolboxExtension)m_application.FindExtensionByCLSID(puid);
    //pArcToolboxExt = (IArcToolboxExtension)m_application.FindExtensionByName("ESRI ArcToolbox");
    IArcToolbox pArcToolBox = pArcToolboxExt.ArcToolbox;
    IGPTool pTol = pArcToolBox.GetToolbyNameString("ScriptSoilQualityMaps");
            
    try
    {
        //pArcToolBox.InvokeTool(m_application.hWnd, pTol, null, false);
        IGPToolCommandHelper comhelp = new GPToolCommandHelperClass();
        comhelp.SetTool(pTol);
        comhelp.Invoke(null);
        m_application.CurrentTool = null;

    }
    catch(Exception ex)
    {
        MessageBox.Show("Model/script Not present in ToolBox.");
        m_application.CurrentTool = null;
    }
    //IGPToolCommandHelper comhelp = new GPToolCommandHelperClass();
    //comhelp.SetTool(pTol);
    //comhelp.Invoke(null);
    // TODO: Add ToolSoilQualityMaps.OnClick implementation
}
comments
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts