<?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: How do I allow user to press escape in command (VB.NET) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5543858#M40968</link>
    <description>&lt;P&gt;Hi Jeff,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try these ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://through-the-interface.typepad.com/through_the_interface/2007/02/allowing_users_.html" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2007/02/allowing_users_.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://adndevblog.typepad.com/autocad/2012/07/allowing-users-to-escape-from-long-operations-in-autocad-net.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/07/allowing-users-to-escape-from-long-operations-in-autocad-net.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The escape should end the command in AutoCAD automatically.&lt;/P&gt;
&lt;P&gt;But your code would still need to recognize another escape to stop sending the next command.&lt;/P&gt;
&lt;P&gt;The code from the blog posts should help recognize the key press.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Mar 2015 05:35:30 GMT</pubDate>
    <dc:creator>Balaji_Ram</dc:creator>
    <dc:date>2015-03-17T05:35:30Z</dc:date>
    <item>
      <title>How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5540540#M40967</link>
      <description>&lt;P&gt;I am using sendcommand to allow users to have access to such functions as INSERT, etc. &amp;nbsp;I need the user to be able to hit the escape key and it takes them completely out of the function. &amp;nbsp;How do I go about doing that in VB.NET?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2015 20:50:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5540540#M40967</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-13T20:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5543858#M40968</link>
      <description>&lt;P&gt;Hi Jeff,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try these ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://through-the-interface.typepad.com/through_the_interface/2007/02/allowing_users_.html" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2007/02/allowing_users_.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://adndevblog.typepad.com/autocad/2012/07/allowing-users-to-escape-from-long-operations-in-autocad-net.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/07/allowing-users-to-escape-from-long-operations-in-autocad-net.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The escape should end the command in AutoCAD automatically.&lt;/P&gt;
&lt;P&gt;But your code would still need to recognize another escape to stop sending the next command.&lt;/P&gt;
&lt;P&gt;The code from the blog posts should help recognize the key press.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2015 05:35:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5543858#M40968</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-03-17T05:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5544959#M40969</link>
      <description>&lt;P&gt;I looked at these posts before, but I didn't think it would benefit my issue properly. &amp;nbsp;I have pasted my code below. &amp;nbsp;There is an insert command that is generated through the sendcommand. &amp;nbsp;I understand that the user can ESC out of the actual command, but I have no way of determining if the INSERT command was actually successful. &amp;nbsp;So, what my code does after the INSERT command is fired is allows the user to select a component. &amp;nbsp;This would be where I would be able to take advantge of the code for ESC, but the focus is once again passed to the user to select a component. &amp;nbsp;Where and how would I put the code into the following example?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim doc As Document = Application.DocumentManager.MdiActiveDocument&lt;/P&gt;&lt;P&gt;Dim db As Database = doc.Database&lt;/P&gt;&lt;P&gt;Dim ed As Editor = doc.Editor&lt;/P&gt;&lt;P&gt;Dim app As AcadApplication = Application.AcadApplication&lt;/P&gt;&lt;P&gt;Using doc.LockDocument()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;app.ActiveDocument.SendCommand("-insert" &amp;amp; vbCr &amp;amp; Flag1Blk &amp;amp; vbCr &amp;amp; "S" &amp;amp; vbCr &amp;amp; "1" &amp;amp; vbCr)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;******** User hit ESC to exit completely out of command, but of course, it just continues executing code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using acTrans As Transaction = db.TransactionManager.StartTransaction()&lt;/P&gt;&lt;P&gt;Dim selectionOpts As PromptSelectionOptions = New PromptSelectionOptions&lt;BR /&gt;selectionOpts.MessageForAdding = "Select the System for the flag to be assigned to."&lt;/P&gt;&lt;P&gt;******** This is second point where user could interrupt code. I would need to add code here so that if ESC&lt;BR /&gt;******** is pressed again, it would exit the function completely.&lt;/P&gt;&lt;P&gt;Dim acSSPrompt As PromptSelectionResult = doc.Editor.GetSelection(selectionOpts)&lt;/P&gt;&lt;P&gt;If acSSPrompt.Status = PromptStatus.OK Then&lt;BR /&gt;Dim acSSet As SelectionSet = acSSPrompt.Value&lt;/P&gt;&lt;P&gt;For Each acSSObj As SelectedObject In acSSet&lt;BR /&gt;If Not IsDBNull(acSSObj) Then&lt;BR /&gt;Dim acEnt As Entity = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForRead)&lt;/P&gt;&lt;P&gt;If Not IsDBNull(acEnt) Then&lt;BR /&gt;LyrVal = acEnt.Layer&lt;BR /&gt;Else&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;P&gt;End Using&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2015 17:23:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5544959#M40969</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-17T17:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5546517#M40970</link>
      <description>&lt;P&gt;In your case, if you need a CAD operation/process not only&amp;nbsp;inserting something, but also doing a lot of thing after, which depend on the result of the inserting, then you'd better CODE your own inserting process, so that you have full control to the workflow, including user's cancellation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using a exasting chunk of process predesigned (SendCommand()/SendStringToExecute()) may simplifies your work, but you have less control to the outcome. As programmer, you need to choose the approach that fits your need. In this particular case, you need to write code to insert, and you can certainly make your insertion look similar or the same as "INSERT" command with the block ghost image changing with user interaction, while having full control to the outcome.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2015 14:12:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5546517#M40970</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2015-03-18T14:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5546531#M40971</link>
      <description>&lt;P&gt;I was looking at going the approach of writing my own INSERT command, but I give up all the functionality of the AutoCAD insert command. &amp;nbsp;The insertion process has to be the same as regular autocad as the user could place the block in question at any rotation, and it is guaged by their feeling at the moment of placement. &amp;nbsp;I just didn't want to have to reinvent the wheel. &amp;nbsp;That is why I want to focus on the escape key capture more than anything else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2015 14:18:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5546531#M40971</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-18T14:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5546910#M40972</link>
      <description>&lt;P&gt;I need the user to be able to break out of any function fired by my application quickly by hitting the escapre key, so really my only solution is to be able to code the app so that whenever the user hits escape, it brings them back to the main application form. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2015 16:52:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5546910#M40972</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-18T16:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5547000#M40973</link>
      <description>&lt;P&gt;I have many functions where I absolutely need to have the ability for the user to hit the escape key. &amp;nbsp;Take a look at the following code where I put the user into a continuous loop to erase objects off the drawing which then deletes records from a database. &amp;nbsp;For efficiency (like most of the commands in my application), I need to keep the user always in the function until escape is hit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim acdoc As Document = Application.DocumentManager.MdiActiveDocument&lt;/P&gt;&lt;P&gt;Dim db As Database = acdoc.Database&lt;/P&gt;&lt;P&gt;Dim ed As Editor = acdoc.Editor&lt;/P&gt;&lt;P&gt;Dim HandleNm As String&lt;BR /&gt;Dim ShortNm As String&lt;BR /&gt;Dim TempStr As String&lt;BR /&gt;Dim FullDir As String&lt;/P&gt;&lt;P&gt;Using acdoc.LockDocument()&lt;/P&gt;&lt;P&gt;ShortNm = TempStr&lt;BR /&gt;Me.Hide()&lt;BR /&gt;Dim counterC As Short&lt;BR /&gt;Dim msgOut As String&lt;BR /&gt;Dim selEntity As Autodesk.AutoCAD.Interop.Common.AcadEntity&lt;BR /&gt;Dim rstFlag As New ADODB.Recordset&lt;BR /&gt;Dim Handle_Renamed As String&lt;BR /&gt;Dim sset As Autodesk.AutoCAD.Interop.AcadSelectionSet&lt;BR /&gt;Dim ArraySize As Short&lt;BR /&gt;Dim selPts() As Object&lt;BR /&gt;Dim Pt As Object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do While counterC &amp;lt; 1000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using acTrans As Transaction = db.TransactionManager.StartTransaction()&lt;/P&gt;&lt;P&gt;'' Request for objects to be selected in the drawing area&lt;/P&gt;&lt;P&gt;Dim selectionOpts As PromptSelectionOptions = New PromptSelectionOptions&lt;BR /&gt;selectionOpts.MessageForAdding = "Select the System Flag for deletion."&lt;/P&gt;&lt;P&gt;Dim acSSPrompt As PromptSelectionResult = acdoc.Editor.GetSelection(selectionOpts)&lt;/P&gt;&lt;P&gt;'' If the prompt status is OK, objects were selected&lt;BR /&gt;If acSSPrompt.Status = PromptStatus.OK Then&lt;BR /&gt;Dim acSSet As SelectionSet = acSSPrompt.Value&lt;/P&gt;&lt;P&gt;'' Step through the objects in the selection set&lt;BR /&gt;For Each acSSObj As SelectedObject In acSSet&lt;BR /&gt;If Not IsDBNull(acSSObj) Then&lt;/P&gt;&lt;P&gt;Dim acEnt As Entity = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite)&lt;/P&gt;&lt;P&gt;If Not IsDBNull(acEnt) Then&lt;BR /&gt;If TypeOf (acEnt) Is BlockReference Then&lt;BR /&gt;Dim blkDel As BlockReference&lt;BR /&gt;blkDel = acEnt&lt;BR /&gt;If InStr(1, blkDel.Name, "FLAG") &amp;gt; 0 Then&lt;BR /&gt;HandleNm = blkDel.Handle.ToString&lt;BR /&gt;'MsgBox(HandleNm)&lt;/P&gt;&lt;P&gt;acEnt.Erase()&lt;BR /&gt;acEnt.Dispose()&lt;BR /&gt;rstFlag.Open("SELECT * FROM FLAG WHERE HANDLE = '" &amp;amp; HandleNm &amp;amp; "' AND PID = '" &amp;amp; ShortNm &amp;amp; "';", dbs, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)&lt;BR /&gt;If rstFlag.EOF = False Then&lt;BR /&gt;rstFlag.Delete()&lt;BR /&gt;rstFlag.Update()&lt;BR /&gt;Else&lt;BR /&gt;End If&lt;BR /&gt;rstFlag.Close()&lt;/P&gt;&lt;P&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;End If&lt;BR /&gt;acTrans.Commit()&lt;/P&gt;&lt;P&gt;End Using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;rstFlag = Nothing&lt;/P&gt;&lt;P&gt;counterC = counterC + 1&lt;BR /&gt;Loop&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2015 17:38:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5547000#M40973</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-18T17:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5547845#M40974</link>
      <description>&lt;P&gt;Hi Jeff,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not find a way to know if the previous SendCommand was cancelled using Escape key.&lt;/P&gt;
&lt;P&gt;As Norman said, you will have less control over the functionality if a series of&amp;nbsp;commands are being sent to complete&amp;nbsp;a task.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Coding the functionality using AutoCAD .Net API or ObjectARX C++ API is a better option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several blog posts on using Jigs for block insertion in Kean's blog post, AutoCAD Devblog, Swamp and the&amp;nbsp;spiderinnet1 blogs.&lt;/P&gt;
&lt;P&gt;You can choose&amp;nbsp;the one that suits your requirements and work with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2015 05:07:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5547845#M40974</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-03-19T05:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5548857#M40975</link>
      <description>&lt;P&gt;ok, I am not so worried about the INSERT command escape, but like I said, I have a bunch of functions that I need the user to be able to hit ESCAPE to exit them out of the function they are in and return them to the main form. &amp;nbsp;In VBA it was automatic. &amp;nbsp;Why can this not be done easily in .NET?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw a post about capturing the autocad command line content and looking for the string *Cancel*, but that seems like a weak solution. &amp;nbsp;I really need to be able to capture the ESCAPE key press.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2015 16:34:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5548857#M40975</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-19T16:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I allow user to press escape in command (VB.NET)</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5548892#M40976</link>
      <description>&lt;P&gt;I do not believe&amp;nbsp;there is such thing that in VBA pressing Esc would just break a chunk of code execution unless it is specifically designed to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is, usually, pressing Esc is used when the code execution is waiting for user input, which is implemented with one of the AcadUtiltity.GetXXX() method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is the same with .NET API: with Editor.GetXXX() method, your can test the PromptResult's status: if Esc is hit, the status is PromptStatus.Cancel. Then your code can do things accordingly: cancelling&amp;nbsp;the code execute, or even let the code continue, you as programmer control it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In .NET, though, the hitting of Esc is handled better: it returns PromptStatus.Cancel, intead of raising an exception in VBA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bottom line is that as accepted AutoCAD user interaction, Esc is used to cancel the code&amp;nbsp;execution when it is waiting for user input. So, if you write code you should do it the same way as standard AutoCAD interaction all users are familia with&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2015 16:57:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-allow-user-to-press-escape-in-command-vb-net/m-p/5548892#M40976</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2015-03-19T16:57:19Z</dc:date>
    </item>
  </channel>
</rss>

