我写了一个 lisp,其中涉及设置一个变量,然后在循环内选择点。一旦我决定完成选择点,我希望能够将该变量恢复为按退出键时的原始状态。例如。
(defun c:df ()
(setq oom (getvar "osmode")) ;store current state
(setq type(getint "\nEnter Type: 1 For Horizontal, 2 For Vertical : "))
(setq startpt (getpoint "\nChoose Start Point : "))
(setq ptx (+ (nth 0 startpt)10))
(setq pty (+ (nth 1 startpt)10))
(setvar "osmode" 2); change state state
(while
(setq nextpt (getpoint "'Pick Mid: ")) ;make selection
(if (null nextpt) ((princ "\nNull Value Error.") return))
(if (= type 1) (command "dimlinear" startpt nextpt "H" (list 0 pty) ))
(if (= type 2) (command "dimlinear" startpt nextpt "V" ptx ))
(setq ptx (+ 5 ptx))
(setq pty (+ 5 pty))
)
;do after escape key is pressed.
(setvar "osmode" oom) ;revert state back to original.
)
我发现可能与“用户输入错误”有关,但实际上无法正常工作。据我所知,当按下转义时,lisp 只是退出并且没有完成执行。
提前致谢。