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!
try and see this link https://github.com/Esri/arcobjects-sdk-community-samples/tree/master/Net/Geoprocessing/GPExecuteToolsAsync
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
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/GeoprocessingExecuteAsync/BufferGeome…
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);
case "OnProgressPos":
string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });
System.Windows.MessageBox.Show(msg2);
}
});
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?
You can find the documentation for tool execution and samples at ArcGIS Pro 1.1 API Reference Guide
Hi Steve,
Here is a link to the documentation: Create Feature Class—Data Management toolbox
Best,
Woody
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.