如何按esc键后,程序继续执行后面的代码
请教一下各位大师,下面有一段代码。[*](defun c:LHcutinoutline ()
[*] (setvar "osmode" 128)
[*] (setvar "orthomode" 1)
[*] (setq chklay (tblsearch "layer" "4"))
[*] (if (= chklay nil) (command "layer" "n" "4" "c" "50" "4" ""))
[*] (setvar "clayer" "4")
[*] (setvar "CECOLOR" "bylayer")
[*] (setvar "CELTYPE" "Continuous")
[*] (command "LINE" PAUSE PAUSE PAUSE PAUSE PAUSE PAUSE )
[*] (setvar "osmode" 0)
[*] (setvar "orthomode" 0)
[*] (princ"\n 垂直引入线第4层") (princ)
[*]);end defun
现在的问题是,按照画图的习惯,一般再第9段程序,画几根直线就会按ESC,一般很少连续画5根直线,这个时候就会按esc结束程序,可是第10-12段就不会执行了,捕捉和正交也不能关闭了。怎么办,有什么办法 再按esc后还可以继续执行后面的程序。
试试这个:
(defun c:Hcutinoutline (/ aa chklay)
(setvar "osmode" 128)
(setvar "orthomode" 1)
(setq chklay (tblsearch "layer" "4"))
(if (= chklay nil) (command "layer" "n" "4" "c" "50" "4" ""))
(setvar "clayer" "4")
(setvar "CECOLOR" "bylayer")
(setvar "CELTYPE" "Continuous")
(setq aa T)
(vl-cmdf "LINE" PAUSE)
(while aa
(if (null (vl-cmdf PAUSE))
(progn
(setvar "osmode" 0)
(setvar "orthomode" 0)
(princ"\n 垂直引入线第4层")
(setq aa nil)
)
)
)
(princ)
)
ssyfeng 发表于 2022-7-27 21:01
试试这个:
第一个想法是定义一个*error*函数,vl-cmdf的办法不错,学习了
(defun c:tt ()
(setq la (getvar 'clayer)os (getvar 'osmode))
(setvar 'osmode 128)
(setvar 'orthomode 1)
(setvar 'celtype "Continuous")
(if (= (tblsearch "layer" "4") nil)
(command "-layer" "n" "4" "c" "50" "4" "S" "4" "")
(setvar "clayer" "4")
)
(command "LINE")
(while (/= 0 (getvar "cmdactive")) (command pause))
(setvar 'osmode os)
(setvar 'orthomode 0)
(setvar 'clayer la)
(princ)
)
页:
[1]