(defun c:TEST (/ LineType)
(initget "L P")
(while (setq LineType
(getkword "\n<L>ine or Polyline: ")
); end of setq
[color=red](if (not LineType)
(setq LineType "L")
)[/color]; end of if
(if (= LineType "L")
(command "._line" pause pause)
); end of if
(while (eq (getvar "cmdactive") 1)
(command pause)
); end of while
(if (= LineType "P")
(command "._pline" pause pause)
); end of if
(while (eq (getvar "cmdactive") 1)
(command PAUSE)
); end of while
[color=green](initget "L P")[/color]
); end of while
(princ)
)
(defun c:test (/ linetype)
(while (or (initget "L P")
(setq linetype (getkword "\nLine or Polyline: ")))
(cond
((= linetype "P") (command "._pline" pause pause))
((command "._line" pause pause))
)
(while (eq (getvar "cmdactive") 1) (command pause))
)
(princ)
)
(or (initget "L P")
(setq linetype (getkword "\nLine or Polyline: ")))
At this point, I can't draw "line" by default by simply hitting the enter key without any letter inputs.
(if (not LineType)
(setq LineType "L")
)
unfortunatly, it doesn't work what I expected.(if
(and
(not (initget "Line Polyline"))
(or (setq option (getkword "\nSelect an option [Line/Polyline]<Line>: "))
(setq option "Line")
)
)
(prompt (strcat "\nYou entered " option))
(prompt "\n** No option entered **")
)
Actually I prefer not using the and/or when doing something like this. I use progn instead ... seeing as the test should have nothing to do with the return value of initget. Not that it's wrong to do so, it's just more clear when reading the code:Many thanks to irneb.Code - Auto/Visual Lisp: [Select]I've done some further alterations, like using cond instead of multiple ifs, simply added the while pause, and added an Exit keyword else the user has no option but to press Esc to stop. But that's off-topic I think.
;;Ask for the keywords + a default
EDIT: Oops! I didn't read all the posts - it seems the OP now wants the 'Exit' to be default...
:lmao:Yeah!!! I know! Funny as hell! :pissed:
(defun c:test ( / lt )
(while
(cond
((initget "Line Pline Exit"))
((not (member (setq lt (getkword "\nLine or Pline? [Line/Polyline/Exit] <Exit>: "))'("Line" "Pline" "Exit"))) nil)
(t
(command (strcat "_." lt))
(while (= 1 (logand 1 (getvar 'cmdactive)))
(command pause)
) t)
)
)
(princ)
)
(= "Exit" ...
perhaps? Else it issues an exit command.(member (...) '("Exit" nil))
EDIT: Oops! I didn't read all the posts - it seems the OP now wants the 'Exit' to be default...
No he wants LINE to be the default until he wants to exit and then he wants EXIT to be the default. :evil:
:lmao:Yeah!!! I know! Funny as hell! :pissed:
Anyhow, I hope I didn't confuse you too much RM :lmao: .
Actually I'm with him on this: The best interface is no interface (http://www.cooper.com/journal/2012/08/the-best-interface-is-no-interface.html/).
Unless they can get some decent brainwave translator going I don't think it's possible though!
Not at all, my friend... Just ribbing you; Happy Friday! :angel:Gathered as much :laugh: . Cheers! I'm off for the weekend :mrgreen:
Actually I'm with him on this: The best interface is no interface (http://www.cooper.com/journal/2012/08/the-best-interface-is-no-interface.html/).An interesting read. Thanks 8-)
Unless they can get some decent brainwave translator going I don't think it's possible though!
(defun c:test (/ lt)
;; Edited from Alan's code
(while
(cond
((initget "Line Pline "))
((member (setq lt
(getpoint
"\nLine or Pline? [Line/Polyline] <Select Point For Line / exit>: "))
'("Line" "Pline"))
(command (strcat "_." lt))
(while (= 1 (logand 1 (getvar 'cmdactive)))
(command pause)
)
t
)
((vl-consp lt);_Select point , run default command "LINE"
(command "_.Line")
(command lt)
(while (= 1 (logand 1 (getvar 'cmdactive)))
(command pause)
)
t)
)
)
(princ)
)