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
}
COMMENT USING
PREMIUM SPONSORS
Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.
Employers - Post Free Jobs
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.