<?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: Cancel active command C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8233556#M24921</link>
    <description>&lt;P&gt;Just to&amp;nbsp;be clear, are you looking to cancel the active command, regardless of what it is?&amp;nbsp; Or to run something when the active command is canceled by whatever method?&lt;/P&gt;</description>
    <pubDate>Wed, 29 Aug 2018 18:52:59 GMT</pubDate>
    <dc:creator>dgorsman</dc:creator>
    <dc:date>2018-08-29T18:52:59Z</dc:date>
    <item>
      <title>Cancel active command C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8231971#M24918</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;although I've seen many questions and answers on this subject none of them works for me except this one:&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("\x03\x03", false, true, false);&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it runs asynchronously and that is not what I want.&lt;/P&gt;&lt;P&gt;Some answers that I found and tried out are more than 10 years old so I guess maybe they used to work on older version of CAD but now they don't.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So to be clear, I need a way to cancel any active command synchronously, using C# and I work in AutoCAD 2018.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;tried&amp;nbsp;to use the Editor.Command() and Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;.ActiveDocument.SendCommand(), but i don't know what string to pass. Tried so many without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help, this is driving me crazy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 09:19:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8231971#M24918</guid>
      <dc:creator>tamara</dc:creator>
      <dc:date>2018-08-29T09:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel active command C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8232764#M24919</link>
      <description>&lt;P&gt;Just&amp;nbsp;install an handler on&amp;nbsp;Document.CommandCancelled event before calling&amp;nbsp;&lt;SPAN&gt;SendStringToExecute(). This way, you'll be able to run your code after the command is cancelled.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 14:22:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8232764#M24919</guid>
      <dc:creator>FRFR1426</dc:creator>
      <dc:date>2018-08-29T14:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel active command C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8233318#M24920</link>
      <description>&lt;P&gt;Interesting suggestion. Thank you very much, but I must say that I'm still hoping to get an answer on how to use Editor.Command(). If no one replays with that I will certainly use your suggestion.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 17:27:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8233318#M24920</guid>
      <dc:creator>tamara</dc:creator>
      <dc:date>2018-08-29T17:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel active command C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8233556#M24921</link>
      <description>&lt;P&gt;Just to&amp;nbsp;be clear, are you looking to cancel the active command, regardless of what it is?&amp;nbsp; Or to run something when the active command is canceled by whatever method?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 18:52:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8233556#M24921</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2018-08-29T18:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel active command C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8234574#M24922</link>
      <description>&lt;P&gt;This is the situation:&lt;/P&gt;&lt;P&gt;In my app, i have a Palette Set with Tool Strip. When user clicks on a button on a Tool Strip a new command is activated. But the problem is that if there is already a command running it won't be canceled. So&amp;nbsp;when a button is pressed in my Pallete Set i need to check if there are any active commands and if so cancel them, and then start the new command.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 07:22:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8234574#M24922</guid>
      <dc:creator>tamara</dc:creator>
      <dc:date>2018-08-30T07:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel active command C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8234625#M24923</link>
      <description>&lt;P&gt;Why are you not putting the command you want to launch after the&amp;nbsp;ETX chars?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Application.DocumentManager.MdiActiveDocument.SendStringToExecute("\x03\x03YOURCOMMAND\n", false, false, false);&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And I think that in your case, you can&amp;nbsp;pass false for&amp;nbsp;wrapUpInactiveDoc as you are working on the active document.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Editor.Command() does not work in an applicationContext (I think it throws an invalid input exception).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 08:08:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8234625#M24923</guid>
      <dc:creator>FRFR1426</dc:creator>
      <dc:date>2018-08-30T08:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel active command C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8308060#M24924</link>
      <description>&lt;P&gt;When exactly does this event get called?&amp;nbsp; Only if a command is cancelled before finishing or whenever a cancel happens?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ask because I have this code and it never calls Document_CommandCancelled&lt;/P&gt;&lt;PRE&gt;Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;doc.CommandCancelled += new CommandEventHandler(Document_CommandCancelled);&lt;BR /&gt;doc.SendStringToExecute("\x03\x03", false, true, false);&lt;/PRE&gt;&lt;P&gt;If this isn't the way to do it, how do I get my code to fire&amp;nbsp;&lt;SPAN&gt;Document_CommandCancelled&lt;/SPAN&gt; after&amp;nbsp;&lt;SPAN&gt;doc.SendStringToExecute?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 18:00:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cancel-active-command-c/m-p/8308060#M24924</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-10-02T18:00:20Z</dc:date>
    </item>
  </channel>
</rss>

