ExecuteToolAsync "FeatureClassToFeatureClass" using "Memory Feature Class" as input

357
2
08-12-2021 07:33 AM
ole1986
New Contributor III

I am struggling with an issue using the `geoprocessing.ExecuteToolAsync` while having feature class in a memory Geodatabase.

The Result after "FeatureClassToFeatureClass" executed is declared with `IsFailed = true` but no errors are displayed (listed in ErrorMessages)

Below is a POC

// "in_memory" or "memory" - both fail
var parameters = Geoprocessing.MakeValueArray("memory\\" + _targetFeatureClass, "C:\SomeOutputDir", "OutputShapeFile");
var environment = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true, workspace: "in_memory", qualifiedFieldNames: false);
var result = await Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass", parameters, environment, null, null, GPExecuteToolFlags.None);


A workaround is to add the FeatureClass as FeatureLayer and use it as parameter 1. E.g.

// WORKING
var layer = ArcGIS.Desktop.Mapping.LayerFactory.Instance.CreateFeatureLayer(_targetFeatureClass, ArcGIS.Desktop.Mapping.MapView.Active.Map);

// Use the "layer" variable instead
var parameters = Geoprocessing.MakeValueArray(layer, shapeFileOutputDir, shapeFileOutputName);
var environment = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true, qualifiedFieldNames: false);
var result = await Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass", parameters, environment, null, null, GPExecuteToolFlags.AddToHistory);


Is this intented to be the correct way when using memory feature classes?

0 Kudos
2 Replies
NobbirAhmed
Esri Regular Contributor

Execution does not fail when I use "memory" as workspace. 

Executing a geoprocessing tool requires not only the tool name but also the toolbox name. Feature Class To Feature Class is in the Conversion toolbox.

So, the correct syntax to use the tool will be:

IGPResult result = await Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass_conversion", parameters, environment, null, null, ExecuteToolFlags.AddToHistory);

IGPResult result = await Geoprocessing.ExecuteToolAsync("conversion.FeatureClassToFeatureClass", parameters, environment, null, null, ExecuteToolFlags.AddToHistory);

If you put the toolbox name after tool name then use an underscore and if using before the tool name then use a dot. Here is an example from Esri github.com site:

https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Geoprocessing/ApplySymbology/Ap...

0 Kudos
ole1986
New Contributor III

Fro me it does not matter if I use "FeatureClassToFeatureClass" or "conversion.FeatureClassToFeatureClass"

But I noticed that I have used a custom name for the memory geodatabase which does not seem to be included when using "memory\\*".

Once I have changed it to the "default" memory geodatabase "memory\\*" as arguments works as expected.

Thanks

0 Kudos