Documentation on 'Geoprocessing.ExecuteToolAsync' ?

3558
6
07-08-2015 03:36 PM
Highlighted
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!

Reply
0 Kudos
6 Replies
Highlighted
Occasional Contributor

Hi Steve,

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

Best,

Woody

Highlighted
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?

Reply
0 Kudos
Highlighted
Esri Contributor

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

- Thomas

Highlighted
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;

                    }

                });

Reply
0 Kudos
Highlighted
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

Reply
0 Kudos
Highlighted
MVP Frequent Contributor
Reply
0 Kudos