下面是一个由我自己编的图块置换的程序,但是每次运行程序时,所要置换的图块总是没有完全置换完,要分好几次置换!请指教,谢谢!
(defun c:th (/ database a c d e f g n da) (setq database (entget (car(entsel "请选择要修改的图块!")))) (PRINT (STRCAT "当前的图块是:" (cdr (assoc '2 database)))) (setq g (cdr (assoc '2 database)))
(setq a (getstring (strcat "\n请输入修改后的图块名:<"(getvar "INSNAME") "> "))) (COND ((/= A "") (setvar "INSNAME" a)) ((= A "") (setq a (getvar "INSNAME"))) ) (setq c (getpoint "the first point:")) (setq d (getcorner c "the second point:")) (setq e (ssget "w" c d)) (setq n (sslength e)) (PRINT N)
(setq f 0) (repeat n (setq da (entget (ssname e f)))
(if (= (cdr (assoc '2 da)) g) (progn (setq da (subst (cons 2 a) (assoc '2 da) da)) (entmod da))
(setq f (1+ f)) ) ))