Geographic Information Systems Asked by Tarragorn on June 7, 2021
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:GISLAB3Post.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);
}
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 + "rn");
for (int i = 0; i < _gp.MessageCount; i++)
messages.AppendLine(_gp.GetMessage(i));
throw new Exception(messages.ToString());
}
Answered by danielm on June 7, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP