Hi,
I would like to use the EditOperation to cut or split a polyline feature at a given MapPoint (snapped to the Polyline). I see I can use either .Cut or .Split method, but the EditOperation does only return a boolean whether it's successful.
How can I get the new feature from the Cut operation? I need to udpate some attributes after cut on both the old and new feature...
Thanks,
The only way to do this at the moment is through the edit events, either editcompleted or the row events, picking up the create and modify feature.
Here's an example of using row events in a cut sketch tool.
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
//Run on MCT
QueuedTask.Run(() =>
{
//get selected feature into inspector
var selectedFeatures = MapView.Active.Map.GetSelection();
var featLayer = selectedFeatures.Keys.First() as FeatureLayer;
var oid = selectedFeatures.Values.First().First();
var insp = new Inspector();
insp.Load(featLayer, oid);
var selGeom = insp.Shape;
var rowCreateToken = RowCreatedEvent.Subscribe(OnRowCreate, featLayer.GetTable());
var rowChangedToken = RowChangedEvent.Subscribe(onRowChanged, featLayer.GetTable());
var editOp = new EditOperation();
editOp.Name = "Split with event";
editOp.SelectModifiedFeatures = true;
editOp.Cut(featLayer, oid, geometry);
editOp.Execute();
RowCreatedEvent.Unsubscribe(rowCreateToken);
RowChangedEvent.Unsubscribe(rowChangedToken);
});
return base.OnSketchCompleteAsync(geometry);
}
private void onRowChanged(RowChangedEventArgs obj)
{
var row = obj.Row;
var rowoid = row.GetObjectID();
row["District"] = "Old";
}
private void OnRowCreate(RowChangedEventArgs obj)
{
var row = obj.Row;
var rowoid = row.GetObjectID();
row["District"] = "New";
}
In the future there will be more ways to monitor changes in an edit session and attribute rules to script actions on certain edit functions like cut/split.