วันจันทร์ที่ 12 กรกฎาคม พ.ศ. 2564

Find Text and Replace

 

;|    

       Find Text and Replace

       - Enter Text String to find

       - Enter Text String to replace

|;

(defun c:FTAR( / ss)

(setq old_cmdecho  (getvar "cmdecho"))

(setvar "cmdecho" 0)

    (or txt (setq txt "ระดับฐาน*"))

    (setq txttemp (getstring t (strcat "\nFind Text: <" txt "> :")))

    (if (= txttemp "")(setq txttemp txt)

              (setq txt txttemp)

       )

;-----------------------------------

       (or ntxt (setq ntxt "ระดับฐาน 100.000 เมตร"))

       (setq ntxttemp (getstring t (strcat "\n Enter Replace Text : <" ntxt ">: " )))

       (if (= ntxttemp "")(setq ntxttemp ntxt)

              (setq ntxt ntxttemp)

       )

;-----------------------------------

    (setq ss (ssget "X" (list(cons 0 "*TEXT")(cons 1 txt))))

    (setq cntr 0

                str null

       )

(if ss

       (while (< cntr (sslength ss))

              (setq en(ssname ss cntr))

              (setq enlist(entget en))

              (setq stxt(cdr(assoc 1 enlist)))    

              (setq str ntxt)

              (setq enlist(subst (cons 1 str)(assoc 1 enlist) enlist))

              (entmod enlist)

              (setq cntr(1+ cntr ))

              (princ)

       );while

    (princ "\nNo text entities found.")

)

(setvar "cmdecho" old_cmdecho)

(princ)

);end

(prompt "\nEnter FTAR to start. Find Text Replace. ")

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

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