Custom Lisp Routines

Discussion in 'AutoCAD' started by Luera, Mar 4, 2004.

  1. Luera

    Luera Guest

    This is my 2 cents for locking and unlocking viewports within a second. Just make sure that your viewport layer "VP" is turned on. Once you place the following into your lisp routines and reload it with your AutoCAD, then you'll just type "VL" to lock your viewport or "VU" to unlock your viewport.

    (DEFUN C:VL ()
    (COMMAND "-VPORTS" "L" "ON" "All" "")
    )
    (DEFUN C:VU ()
    (COMMAND "-VPORTS" "L" "OFF" "All" "")
    )

    Anybody got anything else to share with us using mutliple command short cuts.
     
    Luera, Mar 4, 2004
    #1
  2. Luera

    ECCAD Guest

    Luera,
    This one edits attributes, I find it useful.

    (defun C:RA ()
    (command "_attedit" "_n" "_y" "" "" "")
    (princ)
    ); end function

    Bob
     
    ECCAD, Mar 4, 2004
    #2
  3. Luera

    Chip Harper Guest

    ;; ***********************************************************************
    ;; * *
    ;; * ZOOMCUT.lsp written by Chip Harper 08-07-02 *
    ;; * Edited to add ZL command on 08-26-02 *
    ;; * Edited to turn off cmdecho on 03-25-03 *
    ;; * Edited ZL point variable names on 03-25-03 *
    ;; * Edited CCME to match standards on 05-11-03 *
    ;; * *
    ;; * Email: *
    ;; * *
    ;; * Homepage: *
    ;; * *
    ;; * Program establishes 2 letter shortcuts for zoom commands *
    ;; * zoom extents = ZE *
    ;; * zoom window = ZW *
    ;; * zoom previous = ZP *
    ;; * zoom all = ZA *
    ;; * zoom center = ZC *
    ;; * zoom dynamic = ZD *
    ;; * zoom scale = ZS *
    ;; * zoom limits = ZL *
    ;; * *
    ;; * Notes: Zoom Limits is not a "Native" command; Basicly it is a zoom *
    ;; * window using drawing limits as pick points. Limits need to *
    ;; * be set prior to using the command, as it will not prompt for *
    ;; * points. *
    ;; * *
    ;; * Because of the simple nature of the programs *
    ;; * no Error Handler is needed or provided. *
    ;; * *
    :: * This program is "Autoloaded" with AutoCAD on my machine *
    ;; * via the profile.mnl file located in the custom directory. *
    ;; * *
    ;; * *
    ;; * This lisp is FREEWARE, you may distribute, copy, edit and/or modify *
    ;; * this program as you see fit. *
    ;; * *
    ;; ***********************************************************************
    ;;
    ;; ****************************************
    ;; * == Error Handler == *
    ;; * *
    ;; ****************************************
    ;;
    ;; none
    ;;
    ;;
    ;; ****************************************
    ;; * == Main Function == *
    ;; * *
    ;; ****************************************
    ;;
    (defun C:ZE () ; Zoom
    Extents
    (setq CCME (getvar "cmdecho")) ; Get
    cmdecho setting
    (setvar "cmdecho" 0) ; Turn
    off cmdecho
    (command "_.ZOOM" "_E")
    (setvar "cmdecho" CCME) ; Reset
    cmdecho
    (princ)
    ) ; End C:ZE.

    (defun C:ZW () ; Zoom
    Window
    (setq CCME (getvar "cmdecho")) ; Get
    cmdecho setting
    (setvar "cmdecho" 0) ; Turn
    off cmdecho
    (command "_.ZOOM" "_W")
    (setvar "cmdecho" CCME) ; Reset
    cmdecho
    (princ)
    ) ; End C:ZW

    (defun C:ZP () ; Zoom
    Previous
    (setq CCME (getvar "cmdecho")) ; Get
    cmdecho setting
    (setvar "cmdecho" 0) ; Turn
    off cmdecho
    (command "_.zoom" "_P")
    (setvar "cmdecho" CCME) ; Reset
    cmdecho
    (princ)
    ) ; End C:ZP

    (defun C:ZA () ; Zoom
    All
    (setq CCME (getvar "cmdecho")) ; Get
    cmdecho setting
    (setvar "cmdecho" 0) ; Turn
    off cmdecho
    (command "_.zoom" "_A")
    (setvar "cmdecho" CCME) ; Reset
    cmdecho
    (princ)
    ) ; End C:ZA

    (defun C:ZC () ; Zoom
    Center
    (setq CCME (getvar "cmdecho")) ; Get
    cmdecho setting
    (setvar "cmdecho" 0) ; Turn
    off cmdecho
    (command "_.zoom" "_C")
    (setvar "cmdecho" CCME) ; Reset
    cmdecho
    (princ)
    ) ; End C:ZC

    (defun C:ZD () ; Zoom
    Dynamic
    (setq CCME (getvar "cmdecho")) ; Get
    cmdecho setting
    (setvar "cmdecho" 0) ; Turn
    off cmdecho
    (command "_.zoom" "_D")
    (setvar "cmdecho" CCME) ; Reset
    cmdecho
    (princ)
    ) ; End C:ZD

    (defun C:ZS () ; Zoom
    Scale
    (setq CCME (getvar "cmdecho")) ; Get
    cmdecho setting
    (setvar "cmdecho" 0) ; Turn
    off cmdecho
    (command "_.zoom" "_S")
    (setvar "cmdecho" CCME) ; Reset
    cmdecho
    (princ)
    ) ; End C:ZS

    (defun c:ZL ( / ZLPT1 ZLPT2) ; Zoom
    Limits
    (setq CCME (getvar "cmdecho")) ; Get
    cmdecho setting
    (setvar "cmdecho" 0) ; Turn
    off cmdecho
    (setq ZLPT1 (getvar "limmin"))
    (setq ZLPT2 (getvar "limmax"))
    (command "_.zoom" "window" ZLPT1 ZLPT2)
    (setvar "cmdecho" CCME) ; Reset
    cmdecho
    (princ)
    ) ; End C:ZL

    (princ)
    ;;
    ;; ****************************************
    ;; * == Load Message == *
    ;; * *
    ;; ****************************************
    ;;
    (prompt "\n ZoomCut.lsp Loaded")
    (prompt "\n Written by Chip Harper")
    (prompt "\n ")
    ;;
    ;; ****************************************
    ;; * == End of File == *
    ;; * *
    ;; ****************************************
    ;;
     
    Chip Harper, Mar 4, 2004
    #3
  4. Luera

    Luera Guest

    Thanks for the info, Chip.

    Check this one out. This one allows you to change the size of text without going through its properties.

    "CT" is the shortcut command for this.

    (DEFUN C:CT (/ A TS N INDEX B1 B C D B2)
    (SETQ A (SSGET))
    (SETQ TS (GETREAL "ENTER NEW TEXT SIZE (REAL NUMBER) "))
    (SETQ N (SSLENGTH A))
    (SETQ INDEX 0)
    (REPEAT N
    (SETQ B1(ENTGET (SSNAME A INDEX)))
    (SETQ INDEX (1+ INDEX))
    (SETQ B (ASSOC 0 B1))
    (IF (= "TEXT" (CDR B))
    (PROGN
    (SETQ C (ASSOC 40 B1))
    (SETQ D (CONS (CAR C) TS))
    (SETQ B2 (SUBST D C B1))
    (ENTMOD B2)
    )
    )
    )
    )
     
    Luera, Mar 4, 2004
    #4
  5. Luera

    Rodney Estep Guest

    Just My 2 cents, but zooming is somingthing that you do more than anything.
    Using autolisp to generate your macro's takes away the ability to use these
    macro's transparently. I do all my zooms using my buttons menu. These are
    very powerfull if you have a digitizer with a 16-button puck. I also
    strongly reccomend that any autocad user get there hands on a Gateway2000
    anykey programmable keyboard. They have an extra set of functiion key down
    the right side that I could not live without. Search Ebay, they are still
    out there. Gateway used to ship these with every computer they sold from
    486>Pentium 1 mine came with a 486 and is still going strong.

    Rodney

    ***MENUGROUP=ACAD

    ***BUTTONS1
    ;
    ^C^C
    '_REDRAW;
    $p0=BASIC $p0=*
    ;
    ;
    ;
    ;
    ^C^C
    ^C^C
    'dimdec 0 'dimAdec 0
    'dimdec 1 'dimAdec 1
    'dimdec 2 'dimAdec 2
    'dimdec 3 'dimAdec 3
    'dimdec 4 'dimAdec 4

    ***BUTTONS2
    '_RTPAN
    'dimdec 4 'luprec 4 'DIST _NEAR \_PERP

    ***BUTTONS3
    '_RTZOOM;
    'Z W \
    'Z P;
    '_matchprop

    ***AUX1
    ;
    ^C^C
    '_REDRAW;
    $p0=basic $p0=*
    rq;
    bh;
    'Z V
    ^C^C
    ^C^C
    ^C^C
    'dimdec 0 'dimAdec 0
    'dimdec 1 'dimAdec 1
    'dimdec 2 'dimAdec 2
    'dimdec 3 'dimAdec 3
    'dimdec 4 'dimAdec 4 'luprec 4

    ***AUX2
    '_RTPAN
    'DIST _NEAR \_PERP

    ***AUX3
    '_RTZOOM
    'Z W \
    'Z P;
    $p0=dim_p $p0=*

    ***AUX4
    'Z V
     
    Rodney Estep, Mar 6, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.