Edit Operation Error Using Clip

398
2
02-21-2022 08:39 PM
ThiPham12
New Contributor III

I tried to use the inspector and edit operation to clip selected feature from a feature class, but I am getting an error at SelectedLayer. I am also not sure how I should address oid. Is this the oid of the new clipped feature class?  Please see my code below. Thanks for your help!

public async Task SelectionLayer_Inspector()
{
await QueuedTask.Run(() =>
{
var MV = MapView.Active;
var MU_Layer = MV.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Contains("MUPOLYGON")).FirstOrDefault();
var SelectedLayer = MV.Map.GetSelection();
var oid = new List<long>();

var inspector = new Inspector();
inspector.LoadAsync(SelectedLayer.Keys.First(), SelectedLayer.Values.First());
var Mukeys = inspector["mukey"];
return Mukeys;

var clipOp = new EditOperation();
clipOp.Name = "clip the selected layer";
clipOp.Clip(MU_Layer, oid, SelectedLayer, ClipMode.PreserveArea);
clipOp.ExecuteAsync();

});
}

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

At first "return Mukeys;" breaks code execution at this point and your clip operation will not be executed.

More information about EditOperation Clip method here:

https://pro.arcgis.com/en/pro-app/2.7/sdk/api-reference/#topic9498.html 

From your question difficult to understand that task do you want to realize. Do you want to clip single feature or selected features? What is your clipping geometry and etc.

From your 

0 Kudos
ThiPham12
New Contributor III

I want to clip the selected feature from MUPOLYGON. I basically want to extract the selected input feature, SelectionLayer that overlay the clip feature, MUPOLYGON. Thanks for your help!

0 Kudos