Jump to content

Lisp lệnh TT trong chủ đề “Lisp Hỗ Trợ Tính Toán Khối Lượng Trên Bản Vẽ”

Lsp ở đây:
(defun c:tt (/ Text mid_point FixTextAngle ||| ang dis hei mid poi pt ptt sty tal)
(defun Text (pt hgt str ang sty)
(entmakex (mapcar '(lambda (x y) (cons x y))
'(0 7 10 40 50 1 72 11 73)
(list "TEXT" sty pt hgt ang str 1 pt 2))))
(defun mid_point (p1 p2) (mapcar '(lambda (x y) (* (+ x y) 0.5)) p1 p2))
(defun FixTextAngle (ang)
(if (and (> ang (* 0.5 pi)) (<= ang (* 1.5 pi)))
(+ ang pi)
ang))
(setq hei 250 ;Thay doi chieu cao chu o day
tal 0
sty (getvar 'TEXTSTYLE))
(if (setq poi (getpoint "\nChon diem: "))
(progn (while (setq ptt (getpoint "\nChon diem tiep theo: " poi))
(setq dis (distance poi ptt)
ang (FixTextAngle (angle poi ptt))
mid (mid_point poi ptt))
(Text (polar mid (+ ang (* 0.5 pi)) hei) hei (rtos dis 2 0) ang sty); 0 -> so chu so thap phan
(setq tal (+ tal dis))
(setq poi ptt))
(and (> tal 0)
(setq pt (getpoint "\nChon diem chen text: "))
(Text pt hei (rtos tal 2 0) 0 sty))));(rtos tal 2 0) 0-> so chu so thap phan
(princ))

Cách dùng

  1. Tải tệp 405787_tt.lsp về máy.
  2. Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
  3. Gõ lệnh TT để chạy lisp.

Mã nguồn 405787_tt.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/165160-lisp-h%E1%BB%97-tr%E1%BB%A3-t%C3%ADnh-to%C3%A1n-kh%E1%BB%91i-l%C6%B0%E1%BB%A3ng-tr%C3%AAn-b%E1%BA%A3n-v%E1%BA%BD/
(defun c:tt (/ Text mid_point FixTextAngle ||| ang dis hei mid poi pt ptt sty tal)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Lisp Hỗ Trợ Tính Toán Khối Lượng Trên Bản Vẽ. Xem đúng bài viết #405787 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 209)