Any options to avoid the darn ENTER keystroke!?

Any options to avoid the darn ENTER keystroke!?

Anonymous
Not applicable
2,938 Views
16 Replies
Message 1 of 17

Any options to avoid the darn ENTER keystroke!?

Anonymous
Not applicable

Help! Are there any LISP or VBA options to avoid having to incessantly use the ENTER keystroke for simple command aliases!? Here is an example to illustrate my question.

 

Goal/Purpose:

My goal and purpose is to create a list of commonly used "shortcuts" (i.e., command aliases) that represent common design and drafting tasks (e.g., creating a polyline). I plan to store these in a file called "MyShortcuts.lsp", and this file would be added to the Startup Suite.

 

To keep things simple, here is a basic example of what would be found in the LSP file.

 

0001.jpg

 

Now, when in any DWG file, I would like to be able to type "NL" and have the polyline tool start right away! For heaven's sake, I do not want to have to also hit the ENTER key after typing "NL". Nor do I want to have to move the mouse cursor to the blue space over the words "NL" to finish executing the command (see screen shot below).

 

0002.jpg

 

Any ideas? Please god let their be an answer. This is driving me crazy.

 

Thanks,
Matt

 

 

 

 

0 Likes
2,939 Views
16 Replies
Replies (16)
Message 2 of 17

maratovich
Advisor
Advisor

It may be better to create a button to perform the lisp. You tried ?

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 3 of 17

ВeekeeCZ
Consultant
Consultant

Unlike in some other softwares, this is not possible in Autocad. Only possible shotcut without need of enter confirmation are F* keys and function keys shift/ctrl/alt combinations - which could be used for your custom lisp command as well.

 

Not sure if you know, but it worth to mention that the ENTER could be done also by SPACEBAR or Rt mouse click. I would say its just matter of habit.

 

Anyway, there is some add-on HERE which may help you, but I did not try it myself.

 

Message 4 of 17

john.uhden
Mentor
Mentor

I believe you can do it using (grread).  Your program would have to include a list of qualified shortcut codes so that the command input function would recognize when an item in the list had been typed.  A problem you will have is when you want to create a new function run by "NL1" when you already have a function run by "NL."  And actually your (grread) function would have to get started somehow and be able to interpret every input you would ever want to use be it from the keyboard or menu or tool palette.

 

Until they invent psychic input, you should probably get friendlier with your Enter keys.  Have you noticed there are two of them?  Plus the spacebar is the biggest key you have.  Take a look; it's right up front in the middle, something even that useless thumb of yours can operate.  The only down side is that it isn't labeled.

John F. Uhden

Message 5 of 17

Anonymous
Not applicable

Thanks BeekeeCZ and John for your replies and suggestions. I will have to experiment and try the spacebar method again.

 

On the other hand, it is almost impossible for me to believe that this can't be done with code. I'm curious; do you perhaps know if their was a liability or patent issue with not allowing the LISP or VBA code to recognize that a user might want to start/initiate a tool (e.g., polyline) without having to also manually initiate an ENTER keystroke? My suspicion is that this is not the case. For example, the universal save command (Ctrl + S) doesn't behave this way. I guess I should be thankful that AutoDesk didn't institute a second window dialog that might pop up and ask: 

 

Do you really want to initiate the polyline tool? Click yes to proceed or no to cancel.

 

Then, maybe for good measure a third, fail-safe window dialog could pop up and inquire:

 

Hey, user. Just wanted to triple check. You sure you really want to perhaps/maybe draw a line? This could be dangerous. Click yes to proceed or no to cancel.

 

Granted these examples are a bit over-the-top, but not by much. I am pretty sure if a mobile phone text messaging app was set up so that after typing a message and hitting the "SEND" button, the messaging app still required you to hit the ENTER key to actually send the message, well, this would drive everyone bonkers and no doubt be a short lived messaging app.

Message 6 of 17

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... if a mobile phone text messaging app was set up so that after typing a message and hitting the "SEND" button....


So you don't  mind hitting Send on a mobile phone, but you do  mind hitting Enter/space to "send" a command to AutoCAD?  I don't see any difference.

 

As @john.uhden has already suggested, what you're asking for would make certain commands and settings completely inaccessible.  If you set up something to be triggered by NL without Enter/space, you could never have access  to something triggered by [John's example] NL1.  And if you then decided you wanted something triggered by just N, you could never have access  to your original NL.  It's a pretty rare letter that isn't the beginning of multiple  commands/options that you might want to get to, which is why you have to inform it that you've completed enough of a designation to pin down what you're after.

Kent Cooper, AIA
Message 7 of 17

john.uhden
Mentor
Mentor
Maybe I am repeating myself (and Kent), but AutoCAD has provided us the
means to make a gazillion commands, but in order to distinguish one from
another we are required to make an additional keystroke to "send" the
command. We must even be careful of the aliases we create... "C" for
circle, "CP" for copy, "L" for line, "LI" for list, and so on. How would
you deal with two daughters, one named Ann and the other named Anna? Oh,
and your cousin Annabelle?

It sounds to me like menu picks would be your preference. I remember how
much stuff I programmed into our Calcomp tablets years ago, and into a
24-button puck. That was serous efficiency. Along with Nth Engine, R12
was tough to beat. But that was 25.5 years ago. Isn't it better that you
no longer need an operator to make a long distance call? Yeah, I know,
those 3 digit area codes are overburdening.

John F. Uhden

Message 8 of 17

Anonymous
Not applicable

Hi Kent,

 

When I hit "send" I have consciously decided and initiated an action to send a text message. I am not required a second, additional step to hit the ENTER key, or to turn the phone upside down, or rotate it 180 degrees to actually send the message. This was the weak analogy/comparison I was trying to make with my example for typing "NL" to start the polyline command.

 

Thanks,
Matt

 

 

0 Likes
Message 9 of 17

Anonymous
Not applicable

Hi John,

 

Thanks for the follow up. Your answers, and another forum thread I found, have confirmed that there is absolutely no way (zilch, nada) to eliminate the extra/redundant ENTER keystroke. I'm going to try my best to adapt and accept this absurdity.

 

Here is my answer/brainstorming to your other hypothetical, or "what if" question. To avoid confusing the computer with "C" for circle or "CP" for copy, perhaps it would be possible to have separate or multiple MyShortcuts.LSP (e.g., MS1.LSP, MS2.LSP, etc.) files. These could be categorized based on context: copy/move commands vs. annotation commands, etc.). Perhaps via LSP or VBA within a DWG file these files could be "remapped" on-the-fly by typing a command alias such as "MS1" plus the ENTER keystroke, or "MS2" plus the ENTER keystroke. So if my present task in a DWG file was annotation-centric, I would load MS2 that just had annotation command aliases within it. I wouldn't need to be worried about copy commands, or my other daughters named Anna or Annabelle as these names wouldn't be listed in the MS2.LSP file that was currently loaded. Does this make sense?

 

Thanks,

Matt

0 Likes
Message 10 of 17

maratovich
Advisor
Advisor

I will repeat my message: #2


It may be better to create a button to perform the lisp. You tried ?


It's easier, more convenient, you do not have to press Inter
For each Lisp you can make your own button, for each team.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 11 of 17

john.uhden
Mentor
Mentor

If that's what you want, yes, it can be done.

Would you like to see some of my LABEL_IT.lsp code that runs almost entirely on (grread)?  The real reason I got into it was to show the user what he was about to pick before he ever picked it, just by moving the cursor over an entity.  It would immediately display my own pseudo-glyphs for snap points of lines, arcs, and polyline segments.  But there is a lot of keyboard interception as well, including ESC.  I'm pretty sure that I never conquered intercepting menu picks, but it never really mattered.  They were more of just an intellectual challenge.

 

Caution:  There are a number of visitors here who don't know squat about AutoLisp; they just want freeware.  I hope you are somewhat facile with the language as I doubt that any of us here will do everything for you.  We're really just here to help out and give a little guidance.

John F. Uhden

0 Likes
Message 12 of 17

stevor
Collaborator
Collaborator

1. If you are a rush, you would have a button to start the c:NL,

2. And another to end it, with a few '^Cs; not an 'Enter' but ok for PLINEs.

S
0 Likes
Message 13 of 17

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

When I hit "send" I have consciously decided and initiated an action to send a text message. I am not required a second, additional step ... to actually send the message. ....


I still fail to see the distinction.  When you hit Enter/space after typing NL, you "have consciously decided and initiated an action to send" the command to AutoCAD.  I don't understand how that is any different from hitting Send on a mobile phone, which you obviously don't  consider to be "a second, additional step."  What you apparently want from AutoCAD seems to me to be equivalent to writing a text message and expecting the phone to know when you're done and send it for you, without  your having to hit "Send."  Am I missing something?

 

[As an aside, I also don't understand the point of defining a command called NL in that way -- does it do anything at all for you that the built-in, already-provided, default PL command alias doesn't  get you?  And I would argue against the description of that as a "New Line" command, and the use of L as part of the command name, since in AutoCAD, a Line is decidedly not  the same thing as a Polyline.]

 

Tool Palette items or Ctr+/Shift+/Alt+ keyboard shortcuts are probably the way to get closest to what you want, as already suggested by others.

Kent Cooper, AIA
0 Likes
Message 14 of 17

Anonymous
Not applicable

Hi Maratovich,

 

I appreciate your suggestion, but it is not the solution I was looking/hoping for. As much fun as it might be to create extra buttons, it would probably be better off to use the native task tool icons that are already created, and to create custom palettes, etc.

 

Kind regards,
Matt

0 Likes
Message 15 of 17

Anonymous
Not applicable

Hi Kent,

 

Thanks for your response. I concur with you. I don't think that we will be able to come to agreement as to the distinction I am trying to make. Based on your input and John's and others, I accept the fact that it is not possible with LISP to avoid the ENTER keystroke or the SPACEBAR keystroke for command aliases. I was just trying my best to confirm that this wasn't the case as I noticed that certain keystroke commands (e.g., to save a file if you press CTRL + S) do not require a redundant ENTER or SPACEBAR keystroke. I was trying to understand if there was a certain, special text string that could be added to the end of a command alias that would execute the ENTER or SPACEBAR keystroke in the defined LISP shortcut file. For instance, I was initially curious if AutoDesk had a special phrase for the ENTER keystroke called "PickleMeSquiggly"

 

(defun cmdoff()(setvar "cmdecho" 0)(princ))
(defun cmdon()(setvar "cmdecho" 1)(princ))

(defun c:nl() (cmdoff)(command "pline" "PickleMeSquiggly") (cmdon)(princ)) ;New Line

 

As you and others have noted, this is not the case. There is nothing that can be added to the LISP function, no special phrase or characters, that executes the ENTER keystroke and starts the polyline command when simply typing only two characters such as "NL" or "PL" or however it is defined in the LISP shortcuts file.

 

Thanks,
Matt

0 Likes
Message 16 of 17

john.uhden
Mentor
Mentor

To get you thinking (some more), here is an excerpt of a larger program that demonstrates the use of the grread function.

Don't be concerned about all my symbol names that start with | (pipe symbol).  That just comes from the early days when local variables weren't really local, so I wanted to easily search the atoms-family for any stragglers I had not set to nil.

 

(defun @track (|prompt |undo |what / 2pt code e laste p lastp v1 v2 |key
                                        |ans |done color size |errobj Vctr Vsize)
      ;; added check for viewctr and viewsize (12-07-03)
      ;; after finding that wheelmouse pans and zooms need to be monitored
      ;; for glyphs to work.
      (@fun "@track")
      (defun 2pt (p)(list (car p)(cadr p)))
      (if (setq color (getenv "AutoSnapColor"))
         (setq color (atoi color))
         (setq color 2)
      )
      (if (setq size (getenv "AutoSnapSize"))
         (setq size (atoi size))
         (setq size 5)
      )
      (setq Vctr  (getvar "viewctr")
            Vsize (getvar "viewsize")
            |ans ""
      )
      (if (not |notprompt)(prompt |prompt))
      (setq |notprompt nil)
      (while (and (not |done)  ;; added ESC catch of grread (01-26-01)
                  (setq |errobj (vl-catch-all-apply 'grread (list 1 14 0))))
         (if
            (or
               (not (equal Vctr (getvar "viewctr") |fuzz))
               (not (equal Vsize (getvar "viewsize") |fuzz))
            )
            (setq v1 nil
                  v2 nil
                  Vctr  (getvar "viewctr")
                  Vsize (getvar "viewsize")
            )
         )
         (if (vl-catch-all-error-p |errobj)
            (setq code '(2 27)) ; 'ESC
            (setq code |errobj)
         )
         (setq |etyp nil
               |key (cadr code)
         )
         (cond
            ((= |key 3)
               (setq |done 1 |ans "Exit")
            )
            ((= |key 27)
               (setq |done 1 |ans "Exit")
               (if (equal Program '@cv_label)(princ "*Cancel*"))
            )
            ((and (= (car code) 3) ; 3=pick
                  (/= |what "PLine")
                ;  (setq p (osnap |key "_quick,_near")) ; removed (04-28-01)
                ;  (setq |pick (nentselp p))   ; removed (04-28-01)
                  (setq |pick (nentselp |key)) ; replaced (04-28-01)
                  (setq p (@getpick |pick |what)))
               (setq |ans p |done 1)
            )
            ((and (= (car code) 3) ; 3=pick
                  (= |what "PLine")
                ;  (setq p (osnap |key "_quick,_near")) ; removed (04-28-01)
                ;  (setq |pick (nentselp p))   ; removed (04-28-01)
                  (setq |pick (nentselp |key)) ; replaced (04-28-01)
                  (setq e (@getpick |pick |what)))
               (if laste
                  (progn
                     (if (> |acadver 13)(sssetfirst))
                     (redraw laste 4)
                  )
               )
               (setq |ans  (subst e (car |pick) |pick) ; fixed 11-10-99 for heavies
                     |p    (nth 1 |pick)
                     |pw   (trans |p 1 0)
                     |done 1
               )
            )
            ((and (= (car code) 5) ; 5=track
                  (/= |what "PLine") ; we don't want to "glyph" PLines
                  (setq |pick (nentselp |key)) ; added 01-26-01 because (osnap) function
                                               ; would fail after catching an 'ESC
                ;  (setq p (osnap |key "_quick,_near")) ; removed (04-28-01)
                ;  (setq |pick (nentselp p))   ; removed (04-27-01)
                  (setq p (@getpick |pick |what))) ; revised (04-27-01)
               (if (/= (type e) 'ENAME)(setq e (car |pick)))
               (if (not (and (equal v1 |v1 |fuzz)(equal v2 |v2 |fuzz)))
                  (progn
                     (@unglyphs v1 v2 size)
                     (setq v1 |v1 v2 |v2)
                     (@glyphs (trans |v1 0 1) color size)
                     (@glyphs (trans |v2 0 1) color size)
                  )
               )
               (if (not (equal lastp p |fuzz))
                  (progn
                     (if lastp (@glyph lastp 0 size))
                     (if (< |acadver 14)(redraw e))
                     (@glyph (setq lastp p) color size)
                  )
               )
            )
            ((and (= (car code) 5) ; 5=track
                  (= |what "PLine")
                  (setq |pick (nentselp |key)) ; added 01-26-01 because (osnap) function
                                               ; would fail after catching an 'ESC
                ;  (setq p (osnap |key "_quick,_near")) ; removed (04-28-01)
                ;  (setq |pick (nentselp p))   ; removed (04-28-01)
                  (setq e (@getpick |pick |what)))
               (if (and (not |nested)(not (equal e laste)))
                  (@grip (setq laste e))
               )
            )
            ((vl-position (car code) '(3 5))
               (if (not |etyp)(setvar "modemacro" "Nothing"))
               (@unglyphs v1 v2 size)
               (if (= (type e) 'ENAME)
                  (if (< |acadver 14)(redraw e)(redraw e 4))
               )
               (if lastp (@glyph lastp 0 size))
               (if laste
                  (progn
                     (if (> |acadver 13)(sssetfirst))
                     (redraw laste 4)
                  )
               )
               (setq v1 nil v2 nil lastp nil laste nil)
            )
            ((= (car code) 25) ; presumably a right click (in R14 it was 12)
               (setq |ans "Style" |notprompt 1 |done 1)
            )
            ;((listp |key)(prin code))
            ((or (= |key 13) (= |key 10) (= |key 32))
   ;            (princ "\n")
               (setq |ans (strcase |ans) |notprompt nil)
               (cond
                  ((= |ans "'_HELP")
                     (repeat (strlen |ans)
                        (princ (chr 8)) (princ " ") (princ (chr 8))
                     )
                     (setq |ans "")
                     (cond
                        ((= |mode "PLine")(@help "POLYLINE MODE"))
                        ((= |mode "Object")(@help "OBJECT MODE"))
                        ((= |mode "Points")
                           (if (= |pmode "Line")
                              (@help "POINT MODE (Line)")
                              (@help "POINT MODE (Arc)")
                           )
                        )
                     )
                  )
                  ((vl-position |ans '("A" "AR" "ARC"))
                     (if (or (= |mode "Points")(= |pmode "Arc"))
                        (progn
                           (repeat (strlen |ans)
                              (princ (chr 8)) (princ " ") (princ (chr 8))
                           )
                           (setq |ans "")
                        )
                        (setq |ans "Arc" |done 1)
                     )
                  )
                  ((vl-position |ans '("L" "LI" "LIN" "LINE"))
                     (if (or (= |mode "Object")(= |pmode "Line"))
                        (progn
                           (repeat (strlen |ans)
                              (princ (chr 8)) (princ " ") (princ (chr 8))
                           )
                           (setq |ans "")
                        )
                        (setq |ans "Line" |done 1)
                     )
                  )
                  ((vl-position |ans '("O" "OB" "OBJ" "OBJECT"))
                     (if (= |mode "Object")
                        (progn
                           (repeat (strlen |ans)
                              (princ (chr 8)) (princ " ") (princ (chr 8))
                           )
                           (setq |ans "")
                        )
                        (setq |ans "Object" |done 1)
                     )
                  )
                  ((vl-position |ans '("PL" "PLI" "PLIN" "PLIN" "PLINE"))
                     (if (= |mode "PLine")
                        (progn
                           (repeat (strlen |ans)
                              (princ (chr 8)) (princ " ") (princ (chr 8))
                           )
                           (setq |ans "")
                        )
                        (setq |ans "PLine" |done 1)
                     )
                  )
                  ((vl-position |ans '("PO" "POI" "POIN" "POINT" "POINTS"))
                     (if (= |mode "Points")
                        (progn
                           (repeat (strlen |ans)
                              (princ (chr 8)) (princ " ") (princ (chr 8))
                           )
                           (setq |ans "")
                        )
                        (setq |ans "Points" |done 1)
                     )
                  )
                  ((vl-position |ans '("" "S" "ST" "STY" "STYL" "STYLE"))
                     (setq |ans "Style" |done 1)
                  )
                  ((vl-position |ans '("U" "UN" "UND" "UNDO"))
                     (if (not |undo)
                        (progn
                           (repeat (strlen |ans)
                              (princ (chr 8)) (princ " ") (princ (chr 8))
                           )
                           (setq |ans "")
                        )
                        (setq |ans "Undo" |done 1)
                     )
                  )
                  ((vl-position |ans '("P" "'P" "PA" "'PA" "PAN" "'PAN"))
                     (setq |ans "")
                     (prompt "\nPress Esc or Enter to exit, or right-click to activate pop-up menu.")
                     (@command "'RTPAN" 0)
                     (prompt |prompt)
                  )
                  ((vl-position |ans '("Z" "'Z" "ZOOM" "'ZOOM"))
                     (setq |ans "")
                     (prompt "\nPress Esc or Enter to exit, or right-click to activate pop-up menu.")
                     (@command "'RTZOOM" 0)
                     (prompt |prompt)
                  )
                  ((vl-position |ans '("ZD" "'ZD"))
                     (setq |ans "")
                     (@command '("'ZOOM" "_D") 0)
                     (prompt |prompt)
                  )
                  ((vl-position |ans '("ZE" "'ZE"))
                     (setq |ans "")
                     (@command '("'ZOOM" "_E") 0)
                     (prompt |prompt)
                  )
                  ((vl-position |ans '("ZI" "'ZI"))
                     (setq |ans "")
                     (@command '("'ZOOM" "1.6XP") 0)
                     (prompt |prompt)
                  )
                  ((vl-position |ans '("ZO" "'ZO"))
                     (setq |ans "")
                     (@command '("'ZOOM" "0.625XP") 0)
                     (prompt |prompt)
                  )
                  ((vl-position |ans '("ZP" "'ZP"))
                     (setq |ans "")
                     (@command '("'ZOOM" "_P") 0)
                     (prompt |prompt)
                  )
                  ((vl-position |ans '("ZW" "'ZW"))
                     (setq |ans "")
                     (@command '("'ZOOM" "_W") 1)
                     (prompt |prompt)
                  )
                  ((vl-position |ans '("E" "EX" "EXI" "EXIT" "X" "XIT"))
                     (setq |ans "Exit" |done 1)
                  )
                  (1 (prompt "\nImproper response.")
                     (prompt |prompt)
                     (setq |ans "")
                  )
               )
            )
            ((and (= |key 8)(> (strlen |ans) 0))
               (setq |ans (substr |ans 1 (1- (strlen |ans))))
               (princ (chr 8)) (princ " ") (princ (chr 8))
            )
            ((not (numberp |key))) ; added (12-07-03)
            ((and (> |key 32) (< |key 127))
               (setq |ans (strcat |ans (princ (chr |key))))
            )
         )
      )
      (@unglyphs v1 v2 size)
      (if lastp (@glyph lastp 0 size))
      (if (< |acadver 14)(redraw))
      (setvar "modemacro" |mm)
      (setq Funs (cdr Funs))
      |ans
   )

John F. Uhden

0 Likes
Message 17 of 17

scooberu
Enthusiast
Enthusiast

Try ""   

two quotes consecutive.

0 Likes