0

When you run a Python script from ArcObject .net, an error occurs, all parameters are correct. ArcMap 10.6

import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True

env.workspace = arcpy.GetParameterAsText(0)
#"D:\GISLAB3\Post.mdb"

#Result = arcpy.GetParameterAsText(1)
Result = arcpy.GetParameterAsText(1)
#"D:\GISLAB3"
Hous = arcpy.GetParameterAsText(2)
#"Postt"  

arcpy.FeatureClassToShapefile_conversion(Hous, Result)



c#
    private void button1_Click(object sender, EventArgs e)
        {
            IGeoProcessor2 gp = new GeoProcessorClass();

            gp.AddToolbox("D:/GISLAB3/Scripts.tbx");

            IVariantArray parameters = new VarArrayClass();
            parameters.Add("D:/GISLAB3/Post.mdb");
            parameters.Add("D:/GISLAB3");
            parameters.Add("New");

            gp.Execute("lol", parameters, null);
        }

enter image description here

0

Wrap your call to Geoprocess.Execute in a try catch and get the output messages. It will likely give you a more useful error:

try
{
    _gp.Execute(process, null);
}
catch (Exception e)
{
    StringBuilder messages = new StringBuilder("Error running " + process.ToolName + "\r\n");
    for (int i = 0; i < _gp.MessageCount; i++)
        messages.AppendLine(_gp.GetMessage(i));
    throw new Exception(messages.ToString());
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.