- ;替换文字和属性指定内容 明经 ZZXXQQ 2013.5.9
- (vl-load-com)
- (defun c:11()
- (SETVAR "CMDECHO" 0)
- (setq SS (ssget "X" (list (cons 0 "INSERT,TEXT"))));;;附带处理单行文本
- (setq S1 (ssget "P" '((0 . "INSERT") (66 . 1))));;;过滤出属性块
- (vl-cmdf "SELECT" SS "")
- (SETQ S88 (SSGET "P" '((0 . "TEXT"))));;;过滤出文本
- (setq i -1)
- (setq s2 (ssname s1 0))
- (setq s20 (getstring "\n请输入要查找的文本内容:"))
- (setq s21 (getstring "\n请输入要替换的文本内容:"))
- (if s88 (progn
- (repeat (sslength s88)
- (setq s83 (entget (ssname s88 (setq i (1+ i)))))
- (setq s84 (cdr (assoc 1 s83)))
- (if (vl-string-search s20 s84)
- (entmod (subst (cons 1 (vl-string-subst s21 s20 s84)) (assoc 1 s83) s83))
- )
- )
- ))
- (if s1 (progn
- (setq i -1)
- (repeat (sslength S1)
- (setq ENT (entget (ssname S1 (setq I (1+ I))))
- ENT1 ENT)
- (while (/= (cdr(assoc 0 (setq ENT1 (entget(entnext(cdr(assoc -1 ENT1))))))) "SEQEND")
- (if (= (cdr(assoc 0 ENT1)) "ATTRIB") (progn
- (setq s15 (cdr(assoc 1 ent1)))
- (if (vl-string-search s20 s15) (progn
- (entmod (subst (cons 1 (vl-string-subst s21 s20 s15)) (assoc 1 ent1) ent1))
- (entmod ent)
- ))
- ))
- )
- )
- ))
- (terpri)
- (SETVAR "CMDECHO" 1)
- (princ)
- )
|