Initget causes lisp routine to halt
I'm trying to implement an undo option in a lisp routine. The lisp routine stops executing at the (initget "Undo") line. Why?
(while
(initget "Undo")
(setq sEntity (nentsel "\nSelect object or [Undo] >"))
(if (= sEntity "U")
(progn
(command "_.vplayer" "_t" sLayer "_c" "")
(command "HASD:ViewportLayerFreeze")
)
(setq sEntName (car sEntity))
)
(setq sCLayer (getvar "CLAYER"))
(setq sLayer (cdr (assoc 8 (entget sEntName))))
(if (= sLayer sCLayer)
(progn
(command "_.layer" "_s" "0" "_off" sLayer "")
(setq sMsg
(strcat
"\nThe selected layer, " sLayer ", is the current layer."
"\nIt has been turned off instead of frozen in the viewport."
)
)
(dcl-MessageBox sMsg "HASD-Info" 2 2)
)
(command "_.vplayer" "_f" sLayer "_c" "") ;this line is the real functionality
)
(princ)
)
0
Comments
-
Your using (initget "Undo") as the test expression for the while statement. Initget returns nil, so while would immediately exit. I assume that you've missed your intended test expression.
I also don't see any statements that end the while loop, which means it would loop endlessly.
Regards,Jason Bourhill
0 -
I want to loop as long as the user is selecting objects and provide the opportunity to undo the last action or layer freeze in this case. I don't really have a test expression?0
-
I included a dummy condition and the tool is working ... thanks.I wish I knew more /0
-
This is a case where using progn is more appropriate I think:
[code](while
(progn
(initget "Undo")
(setq sEntity (nentsel "\nSelect object or [Undo] >"))
)
...
)[/code]0
This discussion has been closed.