AnsweredAssumed Answered

How can I execute the custom Toolbox model that contains a script file?

Question asked by tkoka3 on Apr 2, 2020
Latest reply on Apr 8, 2020 by Hornbydd


 I want to execute  the Toolbox ("Toolbox.tbx") model ("ModelScript") that contains a script ("") file but gives exception. I want to copy table values to excel from model .I run correct from arcmap open ModelScript model and run , but programaticly not .I'm using ArcObject sdk for .net . How Can I solve this problem?


Here is the arcobjects code below:
IGeoProcessorResult result;
IGeoProcessor2 gp = new GeoProcessorClass();


gp.AddToolbox(@"C:\Users\.....\Desktop\Bolge\TEST.gdb\Toolbox.tbx");  //Toolbox

gp.OverwriteOutput = true;


IVariantArray parameters = new VarArrayClass();
parameters.Add(@"C:\Users\.....\Desktop\Bolge\TEST.gdb\table");  //Parameter


object sev = null;
try {

result = gp.Execute("ModelScript", parameters, null);   //Model   }

catch (Exception ex){MessageBox.Show(gp.GetMessages(ref sev)); }



Here is the "" code below:

# Name:

import arcpy

# Set environment settings
arcpy.env.workspace = "C:\Users\.....\Desktop\Bolge"

# Set local variables
in_table = "TEST.gdb/table"
out_xls = "addresses.xls"

# Execute TableToExcel
arcpy.TableToExcel_conversion(in_table, out_xls)


Here is prictures of model in ArcMap :






Here is te error from ArcObject .net :

Error HRESULT E_FAIL has been returned from a call to a COM component.


System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at ESRI.ArcGIS.Geoprocessing.GeoProcessorClass.IGeoProcessor2_Execute(String Name, IVariantArray ipValues, ITrackCancel pTrackCancel)