I've built a method that does create a FeatureLayer (temp_layer). And once that FeatureLayer is created, it is used in a clip operation.
But the clipping part does not work because it cannot recognize the featurelayer (temp_layer).
It's probably linked to the async process.
Anybody has a suggestion about that problem?
Here's the piece a code that does what I've said:
/// <summary>
/// Execute the MakeFeatureLayer Tool in the ArcMap Toolbox.
/// Followed by a clip on that featurelayer.
/// </summary>
/// <returns></returns>
/// <remarks></remarks>
public static async Task<bool> ExecuteMakeFeatureLayerAndClipAsync(string _inputFeatures,
string _outputLayer,
string _clipFClassPath,
string _whereClause = "",
string _workSpace = "",
string _field_Info = "")
{
var environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);
List<object> arguments = new()
{
_inputFeatures,
"temp_layer",
_whereClause,
_workSpace,
_field_Info
};
IGPResult result = await Geoprocessing.ExecuteToolAsync("management.MakeFeatureLayer", Geoprocessing.MakeValueArray(arguments.ToArray()), environments, null, null, GPExecuteToolFlags.None);
if (result.IsFailed)
{
Geoprocessing.ShowMessageBox(result.Messages, "GP Messages", GPMessageBoxStyle.Error);
}
arguments = new()
{
"temp_layer",
_clipFClassPath,
_outputLayer,
""
};
result = await Geoprocessing.ExecuteToolAsync("analysis.Clip", Geoprocessing.MakeValueArray(arguments.ToArray()), environments, null, null, GPExecuteToolFlags.None);
if (result.IsFailed)
{
Geoprocessing.ShowMessageBox(result.Messages, "GP Messages", GPMessageBoxStyle.Error);
}
return !result.IsFailed;
}