<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcMap add-in: How to add button operation to undo/redo stack in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-add-in-how-to-add-button-operation-to-undo/m-p/592899#M15957</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll want to use IEditor&amp;nbsp;startediting/stopediting and startoperation/stopoperation&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 May 2019 16:12:03 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2019-05-31T16:12:03Z</dc:date>
    <item>
      <title>ArcMap add-in: How to add button operation to undo/redo stack</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-add-in-how-to-add-button-operation-to-undo/m-p/592897#M15955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've built an add-in with several buttons which initiate an editing session to perform their actions. I would like to push the operation to ArcMap's operation stack so the undo/redo buttons are enabled, but I can't figure out how.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a snippet of the action of one button. This one reduces the font size of all selected features. Is it possible to add this operation to the stack after it is used?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;IFeatureLayer currLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; currMap&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;j&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; IFeatureLayer&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
ISelectionSet ss &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IFeatureSelection&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;currLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectionSet&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ss&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Count &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt; currLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FeatureClass&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;FindField&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;attributeName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    IWorkspaceEdit wse &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IDataset&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;currLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FeatureClass&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Workspace &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; IWorkspaceEdit&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    wse&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;StartEditing&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;true&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    wse&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;StartEditOperation&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

    &lt;SPAN class="comment token"&gt;//Update all annotations in the selection set&lt;/SPAN&gt;
    IFeature currFeature&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; attributeIndex&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    IEnumIDs ids &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ss&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;IDs&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    ids&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Reset&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; id &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ids&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Next&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;id &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        currFeature &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; currLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FeatureClass&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;GetFeature&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        attributeIndex &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; currFeature&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Class&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;FindField&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;attributeName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        currFeature&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Value&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;attributeIndex&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; currFeature&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Value&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;attributeIndex&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        currFeature&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Store&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        id &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ids&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Next&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ActiveView&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Refresh&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    wse&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;StopEditOperation&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    wse&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;StopEditing&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;true&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:27:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-add-in-how-to-add-button-operation-to-undo/m-p/592897#M15955</guid>
      <dc:creator>CoryDavis</dc:creator>
      <dc:date>2021-12-12T01:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap add-in: How to add button operation to undo/redo stack</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-add-in-how-to-add-button-operation-to-undo/m-p/592898#M15956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if this is a red herring but if you look at the remarks on this &lt;A href="http://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#IOperationStack.htm"&gt;IOperationStack&lt;/A&gt;&amp;nbsp;it says:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;If you are outside an editsession and updating a geodatabase directly, calls to IWorkspaceEdit::StartEditOperation and StopEditOperation will not automatically add anything to ArcMap’s OperationStack since these interfaces are independent of ArcMap, and these changes will be made directly to the geodatabase.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code is making direct changes to the FeatureClass and not through the main UI, so may be not possible to do an undo?&amp;nbsp; Some discussion &lt;A href="https://gis.stackexchange.com/questions/3072/how-do-i-get-the-current-undo-and-redo-item-in-arcmap-operation-stack"&gt;here&lt;/A&gt; but not sure if that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May be you can create your own stack and have the ability to reverse your calculations but I would imagine that would be significant coding for all but the simplest scenarios?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 May 2019 11:44:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-add-in-how-to-add-button-operation-to-undo/m-p/592898#M15956</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2019-05-31T11:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap add-in: How to add button operation to undo/redo stack</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-add-in-how-to-add-button-operation-to-undo/m-p/592899#M15957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll want to use IEditor&amp;nbsp;startediting/stopediting and startoperation/stopoperation&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 May 2019 16:12:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-add-in-how-to-add-button-operation-to-undo/m-p/592899#M15957</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-05-31T16:12:03Z</dc:date>
    </item>
  </channel>
</rss>

