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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 3, 2014 at 21:41

1 Answer 1

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

answered Sep 3, 2014 at 23:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.