3

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.

3

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).

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.