PDA

View Full Version : create typed shortcut for command group



archiasmo954906
2012-10-29, 06:55 PM
How do I create a typed short form command for a group of associated commands? For example, I would like to type ZD for Zoom Dynamic, instead of Z enter D. Also ZW for Zoom Window, instead of Z enter W, ZE for Zoom Extents, etc. Thanks!

BlackBox
2012-10-29, 07:39 PM
Welcome to AUGI. :)



(defun c:ZD () (command "._zoom" "dynamic") (princ))
(defun c:ZW () (command "._zoom" "window") (princ))
(defun c:ZE () (command "._zoom" "extents") (princ))




** Moderator - Please move this thread to the LISP forum. :beer:

archiasmo954906
2012-10-29, 08:48 PM
Thanks!! I tried typing this in the command line, and it worked, but only in the drawing I had open. If I close the drawing and open a new one, the command doesn't work anymore. Also, if I close out of Autocad and reopen, the new command disappears. Is there something else I need to do to make the command change permanent? Thanks for your help!

BlackBox
2012-10-29, 08:59 PM
Unfortunately, AutoLISP and Visual LISP code only exist within the document in which it (the source-code) is loaded.

For your new additions to be included automagically in each document you open, you'll need to incorporate a LOAD (http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff1a32d8d10ebc6b7ccc-69c2.htm), or an AUTOLOAD (http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6a96.htm) statement for each LISP file (.lsp) you want to be made available, within your AcadDoc.lsp file.

HTH

archiasmo954906
2012-10-29, 09:54 PM
I eventually figured how to put the code into an autolisp file and set it to automatically load whenever I openAutocad. I am just inputting different command groups based on the code you sent me, and it seems to be working every time. Thank you very much!!

BlackBox
2012-10-29, 10:01 PM
I eventually figured how to put the code into an autolisp file and set it to automatically load whenever I openAutocad. I am just inputting different command groups based on the code you sent me, and it seems to be working every time. Thank you very much!!

You're welcome; I'm happy to help :beer: