Mouse vs keyboard Hint needed

TCEBob

Usenet Archive
Joined
Jul 3, 2003
Messages
327
Reaction score
0
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
 
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
 
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))
 
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
 
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
 

Member Recommended

Latest threads

Back
Top