Jump to content

Tính độ dài cung tròn và Spline

Cách dùng

  1. Tải tệp 213654_ttt.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 TTT để chạy lisp.

Mã nguồn 213654_ttt.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/66714-h%E1%BB%8Fi-t%C3%ADnh-%C4%91%E1%BB%99-d%C3%A0i-cung-tr%C3%B2n-v%C3%A0-spline/

(defun c:ttt(/ #sset #Bacc i #tong #tong1 #ssname #ename #dau #cuoi #ent #dis #point)
 (vl-load-com)  (setvar "CMDECHO" 0)  (command ".undo" "BE")
;  (command ".UCS" "W" ^C^C) ;sai
 (command ".UCS" "W"
 (Prompt "\n- Ch\U+1ECDn \U+0111o\U+1EA1n th\U+1EB3ng c\U+1EA7n tính t\U+1ED5ng: ")
 (setq #sset (ssget ":N" '((0 . "*LINE,PLINE,ARC,ELLIPSE")))) ;thua PLINE
 (setq #Bacc (getint "\n- Nh\U+1EADp s\U+1ED1 l\U+1EBB: "))
 (if (null #Bacc) (setq #Bacc 2))
 (setq i 0)
 (setq #tong 0)
 (while
; (setq #ssname (ssname #sset i))
(setq #ename (ssname #sset i))
; (setq #ename (cdr (assoc 0 (entget #ssname)))) ;khong phai ename
(setq #dis (vlax-curve-getDistAtParam #ename (vlax-curve-getEndParam #ename)))          
(setq #tong (+ #tong #dis))
(setq i (1+ i))  );WHILE
 (setq #tong1 (rtos #tong 2 #Bacc))
 (setq #point (getpoint "\n- Ch\U+1ECDn \U+0111i\U+1EC3m chèn k\U+1EBFt qu\U+1EA3: "))
 (command ".text" "J" "MC" #point 1.7 0 #tong1)
 (command ".undo" "E")
 (princ)
 (princ)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [Hỏi] Tính độ dài cung tròn và Spline. Xem đúng bài viết #213654 để đọc hướng dẫn và trao đổi thêm.

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