Documentation on 'Geoprocessing.ExecuteToolAsync' ?

5479
6
07-08-2015 03:36 PM
SteveHenningsgard
New Contributor II

I'm trying to create a Feature Class using the "Create Feature Class" Geoprocessing tool, and I'm having a heck of a time finding any documentation on how to accomplish this!

0 Kudos
6 Replies
WoodyHynes
Esri Contributor

Hi Steve,

Here is a link to the documentation: Create Feature Class—Data Management toolbox

Best,

Woody

SteveHenningsgard
New Contributor II

Thanks for the resource! I'm wondering how to translate the arcpy code to C# (as I'm working with the SDK). Alternately, would it make more sense to create a custom tool and simply call it from the C# module?

0 Kudos
ThomasEmge
Esri Contributor

You can find the documentation for tool execution and samples at ArcGIS Pro 1.1 API Reference Guide

- Thomas

SteveHenningsgard
New Contributor II

Yeah, that's where I've been looking:

https://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic8624.html

The documentation doesn't really help, although the community sample has gotten me closer (I think?):

https://github.com/Esri/arcgis-pro-sdk-community-samples/edit/master/Geoprocessing/GeoprocessingExec...

I believe the issue I'm having is in creating valid parameters to pass to the tool. I'm getting an 'index out of range' error, and the only array I'm passing is the one generated by MakeValueArray. My test code is as follows:

string toolPath = "data.CreateFeatureclass";

                object[] args = {

                                @"c:\data\test2.gdb",

                                @"ProgrammaticallyGeneratedFeatureClass",

                                @"POINT",

                                null,

                                @"DISABLED",

                                @"ENABLED",

                            };

                var myParams= Geoprocessing.MakeValueArray(args);

                var _cts = new System.Threading.CancellationTokenSource();

                IGPResult x = await Geoprocessing.ExecuteToolAsync(toolPath, myParams, null, _cts.Token, (event_name, o) =>  // implement delegate and handle events

                {

                    switch (event_name)

                    {

                        case "OnValidate": // stop execute if any warnings

                            if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))

                                _cts.Cancel();

                            break;

                        case "OnProgressMessage":

                            string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });

                            System.Windows.MessageBox.Show(msg);

                            _cts.Cancel();

                            break;

                        case "OnProgressPos":

                            string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });

                            System.Windows.MessageBox.Show(msg2);

                            _cts.Cancel();

                            break;

                    }

                });

0 Kudos
ThomasEmge
Esri Contributor

Your code looks and works fine. The only difference I have is

string toolPath = "CreateFeatureclass_management";

If I use your code as is, then the tool is never executed which I am suspecting is due to the incorrect tool path.

My guess would be that your 'index out of range' error has a different origin.

- Thomas

0 Kudos
nicogis
MVP Frequent Contributor
0 Kudos