Mouse vs keyboard Hint needed

Discussion in 'AutoCAD' started by TCEBob, Jan 30, 2004.

  1. TCEBob

    TCEBob Guest

    I have a lisp macro called qw that changes most everything you click on
    to a pline then adjusts the width to a variable. Very nice. But I needed
    to build in a little dialog to change the width parameter. Now the macro
    requires 2 clicks to get going if I accept the default width. Not quick
    enough for me. I need to tell the macro to accept upon the first mouse
    pick (entsel) or change the variable upon seeing a keypress. Where do I
    start? (Please, no vba just now.) Would that be a reactor?

    rs
     
    TCEBob, Jan 30, 2004
    #1
  2. TCEBob

    morrisde Guest

    Look into the (initget) function, you can use that right before the (entsel), you'll need a keyword though (hope that doesn't slow things up too much for you):

    How about
    (initget 128 "w W")
    (setq ent (entsel))
    (if (or (= ent "w") (= ent "W"))
    (change width routine)
    (modify entity routine)
    )

    Hope that helps,
    Dave
     
    morrisde, Jan 30, 2004
    #2
  3. TCEBob

    TCEBob Guest

    Dave, that is spooky! Where did you learn it -- or did you figure it out
    by yourself? Here's the routine. There are some loose ends but it's
    working. Alas, initget won't accept decimal points; that would really be
    nice. I'd still like to know how to distinguish between a keystroke and
    a mouse click, though.

    rs

    (defun c:qw (/ pln pnam) ; quick change pline width. plw is global
    (setvar "peditaccept" 1)
    (setq plw (if plw plw 0))
    (princ (strcat "\nPresent pline width: " (rtos plw)))
    (initget 128 "W w") ;user may enter w or select something.
    (setq pln (entsel "\nPick a WIDENABLE entity (or enter W to change
    width): "))
    (if (member pln '("W" "w")) ;user entered w and did not pick an entity
    (progn
    (setq plwx (getreal "\nNew Pline width: ")) ;set new plw
    (setq plw (if plwx plwx plw))
    (princ (strcat "\nPline width: " (rtos plw)))
    )
    )
    (while t ;now pln is either "w" or an entity
    (setq pln
    (if (member pln '("W" "w"))
    (entsel "\nPick a WIDENABLE entity: ")
    pln
    )
    )
    (setq pnam (cdr (assoc 0 (entget (car pln)))))
    (if (member pnam '("POLYLINE" "LWPOLYLINE" "LINE" "ARC"))
    (command "pedit" pln "w" plw "")
    (princ (strcat "\nCan't widen this " pnam "!"))
    )
    (setq pln "w") ;set up the next loop
    )
    (princ))
     
    TCEBob, Jan 30, 2004
    #3
  4. TCEBob

    morrisde Guest

    Nothing spooky I'm afraid - (initget) and (entsel) are well documented in Developer Help in AutoCAD.
    Thank you for sharing your finished code.
    Regards,
    Dave
     
    morrisde, Jan 31, 2004
    #4
  5. TCEBob

    TCEBob Guest

    Now, don't be harsh on yourself. I've read the documentation many times
    by now but it never occurred to me to use it in this odd way. Good
    thinking is the ability to see the unapparent -- and put it to use.

    Thanks, again

    rs
     
    TCEBob, Feb 1, 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.