วันอาทิตย์ที่ 6 ธันวาคม พ.ศ. 2563

TEXT_VALS

 


(defun c:txtvl (/ ss i tv vl min_val max_val avg_val)

       (while (not ss)

        (princ "\nSelect Text To Calulate...")

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

       )

       (setq i (sslength ss))

       (while (not (minusp (setq i (1- i))))

              (setq tv (cdr (assoc 1 (entget (ssname ss i)))))

              (setq vl (cons (atof tv) vl))

       )

       (setq min_val (apply 'min vl)

                max_val (apply 'max vl)

                avg_val (/ (apply '+ vl) (length vl))

       )

       (setq txt   (strcat "\n Max. " (rtos max_val 2 2)

                                         "\n Avg. " (rtos avg_val 2 2)

                                         "\n Min. " (rtos min_val 2 2)

                           )     

       )

       (setq p1 (getpoint "\nText Position:"))

       (entmake

              (list

                     '(0 . "MTEXT")

                     '(100 . "AcDbEntity")

                     '(100 . "AcDbMText")

                     (cons 10 p1)

                     (cons 7  (getvar "TextStyle")) ; Current Style

                     (cons 40 (getvar "TextSize"))  ; Current height

                     (cons 41 0) ; 0 Width = no wrap

                     (cons 71 1) ; 1 = Top Left

                     (cons 50 0.0) ; rotation angle

                     (cons 1 txt)

              )

       )     

(princ)

);end

(prompt "\nEnter TXTVL to start. ")

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

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