Can Python toolboxes be used with ArcObjects GeoProcess.AddToolbox?
I'm trying to execute a tool in a Python toolbox (.pyt) from .NET.
First I call:
GP.AddToolbox(@"C:\path\to\MyToolbox.pyt")
And that call doesn't get an error. Then I build the parameter list and then I execute it like this:
result = (IGeoProcessorResult2)GP.Execute("ToolName", parameters, null);
This immediately throws the "Error HRESULT E_FAIL has been returned from a call to a COM component." error, so nothing is returned to result.
My next step is to create a dummy script and build it into a .tbx toolbox and leave the .NET code the same to see if it's something else, but it did make me wonder if this is even possible. I couldn't fine any examples of using AddToolbox with a .pyt file.
1 Answer 1
Yes, .pyt toolboxes work just as well as .tbx toolboxes.
Be aware that parameter mismatches will cause the HRESULT E_FAIL message instead of something meaningful being returned (that's what was throwing me off when a simple toolbox worked, but my .pyt would not).
Explore related questions
See similar questions with these tags.