In ArcObjects, I commonly used MakeFeatureLayer to create a layer from a Feature Class, which I then worked with further, for example for spatial selections. When I try to do the same thing in ArcGIS Pro, I get the following error message: ERROR 000732: Selecting Features: Dataset Extent_lyr does not exist or is not supported.
await QueuedTask.Run(async () =>
{
string pathToFgdb = @"C:\ISSMD\Temp\Masking.gdb";
string nameExtent = "Extent";
string nameMasks= "Masks";
string pathToFcExtent = Path.Combine(pathToFgdb, nameExtent);
string pathToFcMasks = Path.Combine(pathToFgdb, nameMasks);
var layerNameExtent = nameExtent + "_lyr";
var layerNameMasks = nameMasks + "_lyr";
var args1 = Geoprocessing.MakeValueArray(pathToFcExtent, layerNameExtent);
IGPResult result1 = await Geoprocessing.ExecuteToolAsync("management.MakeFeatureLayer", args1, null, null, null, GPExecuteToolFlags.AddToHistory);
var args2 = Geoprocessing.MakeValueArray(pathToFcMasks, layerNameMasks);
IGPResult result2 = await Geoprocessing.ExecuteToolAsync("management.MakeFeatureLayer", args2, null, null, null, GPExecuteToolFlags.AddToHistory);
IGPResult result3 = await GeoProcesy.GeoprocessingovaUlohaVysledek("management.SelectLayerByLocation",
[layerNameMasks, "INTERSECT", layerNameExtent, "", "NEW_SELECTION", "NOT_INVERT"]);
});
}So is it even possible to do it this way or do I have to do it only like this?
FeatureLayer featureLayer = LayerFactory.Instance.CreateLayer<FeatureLayer>(featureLayerParams, map);
Solved! Go to Solution.
Hi,
You can use MakeFeatureLayer to create a layer from a Feature Class, but you need to change GPExecuteToolFlags from:
GPExecuteToolFlags.AddToHistoryto:
GPExecuteToolFlags.AddOutputsToMap | GPExecuteToolFlags.AddToHistoryArcGIS Pro geoprocessing without GPExecuteToolFlags.AddOutputsToMap doesn't add layer to map, why your management.SelectLayerByLocation can't find layer from input parameters.
Hi,
You can use MakeFeatureLayer to create a layer from a Feature Class, but you need to change GPExecuteToolFlags from:
GPExecuteToolFlags.AddToHistoryto:
GPExecuteToolFlags.AddOutputsToMap | GPExecuteToolFlags.AddToHistoryArcGIS Pro geoprocessing without GPExecuteToolFlags.AddOutputsToMap doesn't add layer to map, why your management.SelectLayerByLocation can't find layer from input parameters.
Hi,
thanks a lot. It works:-)
So there is no way to do it without adding a layer to a map?
I don't know another way. You can try to run all your code in Python without using Geoprocessing (call python code from .NET)