วันอาทิตย์ที่ 26 เมษายน พ.ศ. 2563

Find Text and Replace


;|     
       Find Text and Replace
       - Enter Old Text String
       - Enter New Text String
|;
(defun C:TRC (/ told tnew tss tdata); = Text Replace for Complete text/mtext strings
(setq old_cmdecho  (getvar "cmdecho"))
(setvar "cmdecho" 0)
;-----------------------------------
       (or told (setq told "Test"))
       (setq told (getstring t (strcat "\nFind Text: <" told "> :")))
       (if (= told "")(setq told "Test"))
;-----------------------------------
       (or tnew (setq tnew "Replace"))
       (setq tnew (getstring t (strcat "\nText Replace: <" tnew "> :")))
       (if (= tnew "")(setq tnew "Replace"))
;-----------------------------------
       (setq tss (ssget "X" (list (cons 1 told))))
       (repeat (sslength tss)
              (setq tdata (entget (ssname tss 0))
                       tdata (subst (cons 1 tnew) (assoc 1 tdata) tdata)
              ); end setq
              (entmod tdata)
              (ssdel (ssname tss 0) tss)
       ); end repeat
(setvar "cmdecho" old_cmdecho)
(princ)      
); end defun
(prompt "\nEnter TRC to start. Find Text and Replace.")

ไม่มีความคิดเห็น:

แสดงความคิดเห็น