[Search tip detail and code files using keywords, tip number, author name, etc ]
 
Two-Key Commands
Tip# 3365 By J.D. Henman On 15-Mar-2010
4.5
Rated By 2 users
Categories : PGP File
Software type : AutoCAD 2010
Rename File To : No Files to download.
Set two-letter keyboard toggles in the ACADDOC.LSP file.

Senior CAD Tech James Henman sent us a few small tips to help you speed things up, especially with two-letter commands.

"These lines are a few of the toggles that I place in my ACADDOC.LSP file so that I can activate them with a two-letter command:
 
(defun c:BM ()(command "setvar" "BLIPMODE" (if (zerop (getvar "blipmode")) 1 0)) )
(defun c:UI ()(command "setvar" "UCSICON" (if (zerop (getvar "ucsicon")) 1 0)) )
(defun c:PM ()(command "setvar" "peditaccept" (if (zerop (getvar "peditaccept")) 1 0)) )
(defun c:FM ()(command "setvar" "fielddisplay" (if (zerop (getvar "fielddisplay")) 1 0)) )
 (defun c:GM ()(command "setvar" "PICKSTYLE" (if (zerop (getvar "pickstyle")) 1 0)) )
 
Replace the bold text with whatever system variable that you want to toggle.

"In ACAD.PGP, make:
 TF,                *TFRAMES

TF will toggle image frames on and off without any prompts.

"I also wrote a short LISP command, as follows, that is auto-loaded to assist with quickly loading a LISP program:
 
(defun c:LL ()
     (setq lfile (strcat (getstring) ".lsp"))
     (setq lostfile (strcat lfile " - File Not Located! "))
     (load lfile lostfile)
)
 
To load a file at the command prompt, I just type:
Command: LL filename<enter>
 
versus
 
Command: (load "filename")<enter>

Notes from Cadalyst Tip Patrol: The key to getting more done in less time is to work less. Keyboard shortcuts are great for that. AutoCAD comes with many commands with two-keystroke abbreviations already set; those are kept in the PGP file. James has also taken advantage of the ACADDOC.LSP file, which is loaded into AutoCAD every time you turn it on. It loads several bits of code, sets variables, and can load LISP routines as well. It is very useful.
 

 

Average Rating:
4.5


User comments
Comment by McSwain,R.K.
Posted on 2010-03-15 14:52:29
You could also do the setvars like this: (setvar "PEDITACCEPT" (abs (1- (getvar "PEDITACCEPT")))) Careful with setvars like PICKSTYLE also, because 0 and 1 are not the only two valid values.
Comment by Anonymous
Posted on 2010-03-17 10:27:24
I use the following very often and created two letter commands too.... Zoom Extent (defun C:ZE () (command "_.ZOOM" "_E")) Zoom Back-off 10% (defun C:Z9 () (command "_.ZOOM" "0.9x")) Circle two points mode (defun C:C2 () (command "_.CIRCLE" "_2")) Note that I use the underscore extensively because I'm from Quebec and I run both French and English versions of AutoCAD Marcel Aubin


Log In