;;method by Alanj
;;modified by reid b.
(defun c:test (/ ss id ent a b)
(setq ss (ssget "_x" '((0 . "text,mtext")))
id 0)
(while (setq ent (ssname ss id))
(if (wcmatch (strcase (cdr (setq a (assoc 1 (setq b (entget ent)))))) "*OLD*")
;;OLD must be uppercase
;;will only modify text with the word old in it
(entmod (subst (cons 1 "NEW") a b))
)
(setq id (1+ id))
)
(princ)
)
(defun c:test ( / old new )
;; © Lee Mac 2010
(setq old "Lee" new "Mac")
(
(lambda ( s i / e )
(if s
(while (setq e (ssname s (setq i (1+ i))))
(entupd
(cdr
(assoc -1
(entmod
(subst
(cons 1 new) (assoc 1 (entget e)) (entget e)
)
)
)
)
)
)
)
)
(ssget "_X" (list (cons 0 "TEXT,MTEXT") (cons 1 old))) -1
)
(princ)
)
^^容易得多 区分大小写。 (defun c:Test (/ new old ss)
(setq new "WoO"
old "Hoo"
)
(if (setq ss (ssget "_X" '((0 . "MTEXT,TEXT"))))
((lambda (i / e s l)
(while (setq e (ssname ss (setq i (1+ i))))
(if (wcmatch (strcase (cdr (setq s (assoc 1 (setq l (entget e)))))) (strcase old))
(entmod (subst (cons 1 new) s l))
)
)
)
-1
)
)
(princ)
) 致李:,
似乎你的代码只会在编写时改变Lee。如果全部是大写或小写,文本将不会更改。这和使用
(ssget“_x”'((1。“Lee”))然后entmod?
是的,我承认我没有读完整的帖子,也不知道区分大小写是个问题。。。 别担心,我只是想学习
页:
1
[2]