In ArcGIS Pro version 2.0.0 I use this code to execute merge tool
public async Task<bool> ExecuteToolAsync()
{
var valueArray = await QueuedTask.Run(() =>
{
// Creates a 8000-meter buffer around the geometry object
// null indicates a default output name is used
return Geoprocessing.MakeValueArray(_inputs, _output);
});
var result = await Geoprocessing.ExecuteToolAsync("Merge_management", valueArray);
return !result.IsFailed;
}
where _inputs is list of fullpath of layers
it works well.
but to execute intersect tool i use this:
public async Task<bool> ExecuteToolAsync()
{
var _inpputs= new List<string>() { _featureLayer1, _featureLayer2 };
var valueArray = await QueuedTask.Run(() => Geoprocessing.MakeValueArray(_inpputs, _outputFeatureClass, "ALL, "0", "POINT"));
var result = await Geoprocessing.ExecuteToolAsync("Intersect_analysis", valueArray);
return !result.IsFailed;
}
It doesn't work. How can I solve this.
Insert this line before your return statement:
Geoprocessing.ShowMessageBox(result.Messages, "Intersect Messages",
result.IsFailed ? GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
Let me know what returned messages do you see. You'll find some snippets in this link:
https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProConcepts-Geoprocessing
Could you please put a break at this line and check what values do you get for valueArray variable when you step-over?
var valueArray = await QueuedTask.Run(() => Geoprocessing.MakeValueArray(_inpputs, _outputFeatureClass, "ALL, "0", "POINT"));
Where (how) are you getting the values of _featureLayer1 and _featureLayer2 - where are these variables defined? How are they defined.
var _inpputs= new List<string>() { _featureLayer1, _featureLayer2 };
Are these Map layer objects obtained from a 'map' object - such as map.GetLayersAsFlattenedList() ... ? If so, you can call GetFeatureClass on both _featureLayer1 and _featureLayer2 as follows:
_featureLayer1.GetFeatureClass() and _featureLayer2.GetFeatureClass() and use these feature classes instead.
@NobbirAhmed , Thanks for your response. It helped me resolve my problem. The only thing I changed was the following:
var _inpputs = new List<FeatureLayer>() {_featureLayer1,_featureLayer2};
A list of feature layer or feature class will work for this geoprocessing tool.
Thanks!