<?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 Calling AutoCAD Undo commands from C#.NET in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/5565446#M40721</link>
    <description>&lt;P&gt;I'm trying to write two methods which call AutoCAD's UNDO command and pass in different parameters. The first method calls UNDO and passes M which means mark the position of the drawing. The second method calls UNDO and passes B which means undo all the way back to the marked position (or the end if there isnt one). So far they are pretty simple&lt;/P&gt;&lt;PRE&gt;        &lt;SPAN&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;/// Method to mark the current position of the AutoCAD program&lt;/SPAN&gt;
        &lt;SPAN&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;static&lt;/SPAN&gt; &lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;MarkPosition&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;
        &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;            doc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SendStringToExecute&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"._UNDO M"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;
        &lt;SPAN&gt;}&lt;/SPAN&gt;

        &lt;SPAN&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;/// Method to step AutoCAD back int steps&lt;/SPAN&gt;
        &lt;SPAN&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;static&lt;/SPAN&gt; &lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;BigUndo&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;
        &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;            doc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SendStringToExecute&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"._UNDO B"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;
        &lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;These look like they should work but for some reason they don't. When I call MarkPosition() and then BigUndo() I get an error saying Start of Group encountered; enter Undo End to go back further. To test my syntax. I changed MarkPosition to&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;static&lt;/SPAN&gt; &lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;MarkPosition&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt; 
&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;    doc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SendStringToExecute&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"circle 2,2,0 4 "&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;
&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;which successfully draws a circle. That means my syntax is right but something weird is going on with Undo.&lt;/P&gt;</description>
    <pubDate>Tue, 31 Mar 2015 16:55:07 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-03-31T16:55:07Z</dc:date>
    <item>
      <title>Calling AutoCAD Undo commands from C#.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/5565446#M40721</link>
      <description>&lt;P&gt;I'm trying to write two methods which call AutoCAD's UNDO command and pass in different parameters. The first method calls UNDO and passes M which means mark the position of the drawing. The second method calls UNDO and passes B which means undo all the way back to the marked position (or the end if there isnt one). So far they are pretty simple&lt;/P&gt;&lt;PRE&gt;        &lt;SPAN&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;/// Method to mark the current position of the AutoCAD program&lt;/SPAN&gt;
        &lt;SPAN&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;static&lt;/SPAN&gt; &lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;MarkPosition&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;
        &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;            doc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SendStringToExecute&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"._UNDO M"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;
        &lt;SPAN&gt;}&lt;/SPAN&gt;

        &lt;SPAN&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;/// Method to step AutoCAD back int steps&lt;/SPAN&gt;
        &lt;SPAN&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;static&lt;/SPAN&gt; &lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;BigUndo&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;
        &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;            doc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SendStringToExecute&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"._UNDO B"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;
        &lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;These look like they should work but for some reason they don't. When I call MarkPosition() and then BigUndo() I get an error saying Start of Group encountered; enter Undo End to go back further. To test my syntax. I changed MarkPosition to&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;static&lt;/SPAN&gt; &lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;MarkPosition&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt; 
&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;    doc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SendStringToExecute&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"circle 2,2,0 4 "&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;
&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;which successfully draws a circle. That means my syntax is right but something weird is going on with Undo.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2015 16:55:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/5565446#M40721</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-31T16:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calling AutoCAD Undo commands from C#.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/8395813#M40722</link>
      <description>&lt;P&gt;Does anyone have an answer for this? I also have the same issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;acDoc.SendStringToExecute("undo 1 ", true, false, false);&lt;/PRE&gt;&lt;PRE&gt;acDoc.SendStringToExecute("._UNDO 1 ", true, false, false);&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Nov 2018 12:30:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/8395813#M40722</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-12T12:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calling AutoCAD Undo commands from C#.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/8396524#M40723</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Difficult to diagnose with so few details about the error (if any), the context, etc.&lt;/P&gt;
&lt;P&gt;The main issue while using SendStringToExecute is it runs asynchronously.&lt;/P&gt;
&lt;P&gt;For AutoCAD 2015 or later, you can try to use the &lt;A href="https://help.autodesk.com/view/OARX/2019/ENU/?guid=OREFNET-Autodesk_AutoCAD_EditorInput_Editor_Command_params_object__" target="_blank"&gt;Editor.Command()&lt;/A&gt; method, for prior version you can use Tony&amp;nbsp; Tanzillo's wrapper for the non-public &lt;A href="https://forums.autodesk.com/t5/net/send-command-executes-after-exiting-command-method/m-p/3882952/highlight/true#M34731" target="_blank"&gt;RunCommand()&lt;/A&gt; method, both work the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;acDoc.Editor.Command("_.undo", 1);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Nov 2018 16:36:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/8396524#M40723</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-11-12T16:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calling AutoCAD Undo commands from C#.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/8397833#M40724</link>
      <description>&lt;P&gt;It does work with Editor.Command() as well as I'd like it to, thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 07:06:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/calling-autocad-undo-commands-from-c-net/m-p/8397833#M40724</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-13T07:06:12Z</dc:date>
    </item>
  </channel>
</rss>

