Repository for Ideas & Research
Open Source GIS, Hydrologic Modeling, Optimization

How to create an edit operation for redo/undo using ArcObjects

IFeatureLayer fl;
IEditor editor;
IWorkspace ws;
ISelectionSet selSet;

fl = yourFeatureLayer;

editor = (IEditor)ArcMap.Application.FindExtensionByName("ESRI Object Editor");
ws = ((IDataset)fl).Workspace;

if (editor.EditState == esriEditState.esriStateNotEditing || editor.EditWorkspace != ws)
{
	throw new ApplicationException("Start an edit session.");
}

// optionally, require selected features
selSet = ((IFeatureSelection)fl).SelectionSet;
if (selSet.Count == 0)
{
	throw new ApplicationException("No features selected.");
}

try
{
	editor.StartOperation();

	// make edits here

	// you'll see this edit under Edit => Undo/Redo
	editor.StopOperation("Name of Edit Operation");
}
catch
{
	editor.AbortOperation();
	throw;
}

Wed Sep 6 07:57:52 2017 EDT by Huidae Cho
Parsing time: 0.013 seconds
XHTML . CSS . Powered by Uniqki!