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!
Hi Steve,
Here is a link to the documentation: Create Feature Class—Data Management toolbox
Best,
Woody
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
- 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?):
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;
}
});
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