วันพฤหัสบดีที่ 15 กรกฎาคม พ.ศ. 2564

U-TURN

 U-TURN


(defun c:u-turn ()

(setq old_cmdecho (getvar "cmdecho"))

(setvar "cmdecho" 0)

(setq st (getpoint "\n Pick Point :")

  p1 (list (car st)(+(cadr st)0.50))

  p2 (list (+(car p1)0.35)(cadr p1))

  p3 (list (car p2)(-(cadr p2)0.25))

  p4 (list (car p3)(-(cadr p3)0.25))

)

(command "_pline" st "W" "0.10" "" p1 "A" p2 "L" p3 "W" "0.30" "0.00" p4 "")

(setvar "cmdecho" old_cmdecho)

(princ)

);end

วันจันทร์ที่ 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. ")

วันพฤหัสบดีที่ 8 กรกฎาคม พ.ศ. 2564

Add Dot decimal point and comma in Text

;|

      Add Dot decimal point and comma in Text

      Ex. Km.1+000000 to Km.1+000.000

      Ex. 1000 to 1000.000

      Ex. 1000000.00 to 1,000,000.00

      Create and Design by Songkhran Jongkul july 2021

|;

(defun c:addc ( / ss)

(setq old_cmdecho  (getvar "cmdecho"))

(setvar "cmdecho" 0)

(initget "1 2 3")

(setq opt (getkword "\nSelect Options :[ 1 Add Decimal Point .000 / 2 Add Number Decimal .123 / 3 Add Comma to Number ] : <1> "))

(if (= opt "")(setq opt "1"))

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

(if (= opt "2")

      (progn

            (or ndec (setq ndec ".123"))

            (setq dectemp (getstring (strcat "\n Enter Decimal : <" ndec ">: " )))

            (if (= dectemp "")(setq dectemp ndec)

                  (setq ndec dectemp)

            )

      )

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

      (progn

            (if (null dec)(setq dec 3))

            (if (setq tmp (getint (strcat "\nEnter Number of Decimal: <" (rtos dec 2 0) ">: ")))

                  (setq dec tmp)

            )

      )

)

 

(setq ss(ssget '((0 . "TEXT,MTEXT"))))

(setq cntr 0

        str null

)

(while (< cntr (sslength ss))

      (setq en(ssname ss cntr))

      (setq enlist(entget en))

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

      (cond

            ((= opt "1")

                  (progn

                        (setq num (strlen stxt)

                                cnt (- num dec)

                        )

                        (setq str (strcat (substr stxt 1 cnt) "." (substr stxt (1+ cnt))))

                  )

            )

            ((= opt "2")(setq str (strcat stxt ndec)))

            ((= opt "3")(setq str (rtoc (atof stxt) dec)))

      )

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

      (entmod enlist)

      (setq cntr(1+ cntr ))

(princ)

);while

(setvar "cmdecho" old_cmdecho)

(princ)

)

 

(prompt "\nEnter ADDC to start. ")

 

(defun rtoc ( n p / d i l x );; n = any number p = precision

      (setq d (getvar 'dimzin))

      (setvar 'dimzin 0)

      (setq l (vl-string->list (rtos n 2 p))

              x (cond ((cdr (member 46 (reverse l)))) ((reverse l)))

              i 0

      )

      (setvar 'dimzin d)

      (vl-list->string

            (append

                  (reverse

                        (apply 'append

                              (mapcar

                                    '(lambda ( a b )

                                          (if (and (zerop (rem (setq i (1+ i)) 3)) b)

                                                (list a 44)

                                                (list a)

                                          )

                                    )

                                    x (append (cdr x) '(nil))

                              )

                        )

                  )

                  (member 46 l)

            )

      )

);end


วันพุธที่ 7 กรกฎาคม พ.ศ. 2564

Add decimal point in Text

 


;|

       Add Dot Command Add decimal point in Text

       Ex. Km.1+000000 to Km.1+000.000

       Create and Design by Songkhran Jongkul july 2021

|;

(defun c:adot ()

(setq old_cmdecho  (getvar "cmdecho"))

(setvar "cmdecho" 0)

(if (null dec)

       (setq dec 3)

)

(if (setq tmp (getint (strcat "\nEnter Number of Decimal: <" (rtos dec 2 0) ">: ")))

       (setq dec tmp)

)

(setq ss(ssget '((0 . "TEXT,MTEXT"))))

(setq cntr 0)

(while (< cntr (sslength ss))

       (setq en(ssname ss cntr))

       (setq enlist(entget en))

       (setq s-tex(cdr(assoc 1 enlist)))   

       (setq num (strlen s-tex)

                cnt (- num dec)

                opt (strcat (substr s-tex 1 cnt) "." (substr s-tex (1+ cnt)))

       )

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

       (entmod enlist)

       (setq cntr(+ cntr 1))

(princ)

)

(setvar "cmdecho" old_cmdecho)

(princ)

)

(prompt "\nEnter ADOT to start. ")