简单的意见,
当我们需要在代码中修改一些系统变量时,可以方便地使用简单的错误处理函数,以确保系统变量将被重置。。。
也许是这样
- (defun c:test (/ *error* old_flg ss)
- (defun *error* (msg)
- (if old_flg (setvar 'qaflags old_flg))
- (princ)
- );; *error*
- (if
- (setq ss (ssget "X" '((0 . "INSERT") (2 . "a11,a12,a13,a14"))))
- (progn
- (setq old_flg (getvar "qaflags"))
- (setvar 'qaflags 3)
- (command "_.explode" ss "")
- );; progn
- );; if
- (*error* nil)
- (princ)
- );; test
还有一种不同的方法,不需要更改系统变量,使用vla sendcommand,我们可以向命令行发送文本字符串,AutoCAD将运行“explode”命令行版本,允许使用命令行选项,包括“previous”,因此
- (defun c:test (/ ss)
- (vl-load-com)
- (if
- (setq ss (ssget "X" '((0 . "INSERT") (2 . "a11,a12,a13,a14"))))
- (vla-sendcommand
- (vla-get-activedocument (vlax-get-acad-object))
- (strcat "explode" " " "p" " " " ")
- )
- );; if
- (princ)
- );; test
希望有帮助
亨里克 |