วันจันทร์ที่ 28 กุมภาพันธ์ พ.ศ. 2565

Edit Left and Right Cross-Section Distance

 


;|    

      Edit Left and Right Cross-Section Distance

Designed and Created February 2022

      - Options Decimal

      - Add Number Bank(Taling)

      - Select object   

|;

(defun c:EDTD (/ ddata)

(setq old_dimzin (getvar "dimzin"))

(setvar "dimzin" 4)

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

(initget "0 0.0 0.00 0.000")

      (setq opt0 (getkword "\nOptions Decimal \n [  0 /  0.0 /  0.00 /  0.000 ] : <0> "))

      (if (= opt0 "") (setq opt0 "0"))

      (cond

            ((if (= opt0 "0")  (setq dec 0))) ;decimal 1

            ((if (= opt0 "0.0")  (setq dec 1))) ;decimal 1

            ((if (= opt0 "0.00")  (setq dec 2))) ;decimal 2

            ((if (= opt0 "0.000")  (setq dec 3))) ;decimal 3

      ); setq

;(setq dec 3)     

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

      (if (not addon) (setq addon 59.0))

      (setq txtMtemp

            (getdist (strcat "\nAdd Number Bank(Taling) : <"

                            (rtos addon 2 dec)

                                     "> : "

                                          ) ;_ strcat

            ) ;_ getdist

      ) ;_ setq

      (if (not txtMtemp) (setq txtMtemp addon) (setq addon txtMtemp))

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

      (princ "Select object (window) :")

      (if (setq dimss (ssget ":L" '((0 . "TEXT,MTEXT"))))

            (progn

                  (setq c -1)

                  (repeat (sslength dimss)

                        (setq ddata (entget (ssname dimss (setq c (1+ c))))

                                str (atof (cdr (assoc 1 ddata)))

                        )

                        (setq ddata (subst

                                                (cons 1 (if (= str addon)

                                                                  (if(= dec 0)(rtos 0.0 2 dec)            ;0

                                                                        (strcat "0"(rtos 0.0 2 dec))  ;0.0 0.00 0.000

                                                                  )

                                                                  (rtos (- str addon)2 dec)

                                                            )

                                                )

                                                (assoc 1 ddata)

                                                ddata

                                          ); subst

                        ); setq

                        (entmod ddata)

                  )

            );progn

      )    

(setvar "dimzin" old_dimzin) 

(princ)

); defun

(prompt "\nCreate and Design by SONGKHRAN JONGKUL February 2022")

(prompt "\nEnter EDTD to start. ")

วันพุธที่ 23 กุมภาพันธ์ พ.ศ. 2565

Add message Text or Dimension

 

;|     

       Add message Text or Dimension

       - Add message

       - front / behind

|;

(defun c:ADTD (/ dimss c ddata); = Dimension Text:

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

       (if (or (not addon) (/= (type addon) 'STR)) (setq addon "เมตร"))

       (setq txtMtemp

              (getstring T (strcat "\npecify text to add message <"

                             addon

                                     "> : "

                                                ) ;_ strcat

              ) ;_ getdist

       ) ;_ setq

       (if (= txtMtemp "") (setq txtMtemp addon) (setq addon txtMtemp))

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

(initget "front behind")

       (setq opt0 (getkword "\nAdd message \n[ front / behind ] : <front> "))

       (if (= opt0 "") (setq opt0 "front"))

       (setq dimss (ssget ":L" '((0 . "MTEXT,DIMENSION")))

                c -1

                dec 2 ;decimal

       ); setq

       (repeat (sslength dimss)

              (setq ddata (entget (ssname dimss (setq c (1+ c)))))

              (print (cdr (assoc 0 ddata)))

              (print addon)

              (cond

                     ((= (cdr (assoc 0 ddata)) "DIMENSION")    

                           (setq ddata (subst

                                                       (cons 1 (if (= opt0 "front")(strcat addon(rtos (cdr (assoc 42 ddata))2 dec))

                                                                                  (strcat (rtos (cdr (assoc 42 ddata))2 dec)addon)

                                                                     )

                                                       )

                                                       (assoc 1 ddata)

                                                       ddata

                                  ); subst & adjusted ddata

                           ); setq

                           (entmod ddata)             

                     );if

                     ((= (cdr (assoc 0 ddata)) "MTEXT")

                           (setq ddata (subst

                                                       (cons 1 (if (= opt0 "front")(strcat addon(cdr (assoc 1 ddata)))

                                                                                  (strcat(cdr (assoc 1 ddata)) "" addon)

                                                                     )

                                                       )

                                                       (assoc 1 ddata)

                                                       ddata

                                                ); subst & adjusted ddata

                           ); setq

                           (entmod ddata)

                     );if

              )

       ); repeat

       (princ)

); defun

(prompt "\nEnter ADTD to start. ")

วันเสาร์ที่ 5 กุมภาพันธ์ พ.ศ. 2565

irregular quadrilateral


|;

       irregular quadrilateral

       by Lengths and angle

       - Enter length 4 side and one angle

       - Create and Design by Songkhran Jongkul 04-02-2022

|;

       (defun tan (x)

       (/ (sin x)(cos x))

       )

       (defun arsin (x)

       (setq y (sqrt (- 1 (* x x))))

       (atan x y)

       )

       (defun arcos (x)

       (- (/ pi 2)(arsin x))

       )

       (defun rtod (x)

       (/ (* x 180) pi)

       )

       (defun dtor (x)

       (* x (/ pi 180))

       )

(defun c:irrq ()

(setq old_cmdecho  (getvar "cmdecho"))

(setq old_osnap (getvar "osmode"))

 

(setvar "cmdecho" 0)

(setvar "osmode" 0)

       (or la (setq la 138.82))     

       (setq latemp (getdist (strcat "\nLength A <" (rtos la 2 2) ">: ")))

       (if (not latemp)(setq latemp la)

              (setq la latemp)

       )

       (or lb (setq lb 83.88))     

       (setq lbtemp (getdist (strcat "\nLength B <" (rtos lb 2 2) ">: ")))

       (if (not lbtemp)(setq lbtemp b)

              (setq lb lbtemp)

       )

       (or lc (setq lc 104.10))    

       (setq lctemp (getdist (strcat "\nLength C <" (rtos lc 2 2) ">: ")))

       (if (not lctemp)(setq lctemp lc)

              (setq lc lctemp)

       )

       (or ld (setq ld 74.7))

       (setq ldtemp (getdist (strcat "\nLength D <" (rtos ld 2 2) ">: ")))

       (if (not ldtemp)(setq ldtemp ld)

              (setq ld ldtemp)

       )

       (or anga (setq anga 88.53)) 

       (setq angatemp (getdist (strcat "\nAngle A <" (rtos anga 2 2) "\U+00B0>: ")))

       (if (not angatemp)(setq angatemp anga)

              (setq anga angatemp)

       )

;----------Calculator length and angle inside--------------------------------

       (setq bd (sqrt(-(+(expt la 2)(expt lb 2))(* 2 la lb (cos (dtor anga))))))

       (setq angd  (rtod(arcos(/(-(+(expt bd 2)(expt la 2))(expt lb 2))(* 2 la bd))))

                angd2 (rtod(arcos(/(-(+(expt ld 2)(expt bd 2))(expt lc 2))(* 2 ld bd))))

                angadc (+ angd angd2)

                angb  (- 180.0(+ anga angd))

                angb2 (rtod(arcos(/(-(+(expt lc 2)(expt bd 2))(expt ld 2))(* 2 lc bd))))

                angabc (+ angb angb2)

                angbcd (- 360.0(+ anga angabc angadc))

       )

;----------------Draw irregular quadrilateral -------------------------------

       (setq pa (getpoint "\n Pick a point a :"))

       (setq pb (polar pa (dtor anga) lb)

                pd (polar pa 0 la)

                pc (polar pd (dtor (- 180.0 angadc)) ld)

       )

       (command "_pline" pa pd pc pb "c")

(setvar "cmdecho" old_cmdecho)

(setvar "osmode" old_osnap)

(princ)

)

(prompt "\nEnter IRRQ to start irregular quadrilateral")

(prompt "\nCreate and Design by Songkhran Jongkul 04-02-2022")