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);
}
Vince
20.5k16 gold badges49 silver badges65 bronze badges
1 Answer 1
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());
}
answered Apr 8, 2019 at 20:01
lang-cs