我必须承认,我通常不会使用“entupd”来更新ATT,因为它有时似乎会导致错误,但请尝试以下方法:
- (defun c:dwgupd (/ ss eLst dNme aEnt aEntLst)
- (vl-load-com)
- (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 "TITLE") (cons 66 1)
- (if (getvar "CTAB")
- (cons 410 (getvar "CTAB"))
- (cons 67 (- 1 (getvar "TILEMODE")))))))
- (progn
- (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
- dNme (vl-filename-base (getvar "DWGNAME")))
- (foreach e eLst
- (setq aEnt (entnext e))
- (while (not (eq "SEQEND" (cdadr (setq aEntLst (entget aEnt)))))
- (if (= "DRAWINGNAME" (cdr (assoc 2 aEntLst)))
- (progn
- (entmod (subst (cons 1 dNme)(assoc 1 aEntLst) aEntLst))
- (entupd e)))
- (setq aEnt (entnext aEnt)))))
- (princ "\n<!> No Title Blocks Found <!> "))
- (princ))
|