lip tính khối lượng thể tích vật liệu
Bạn thử đoạn code, Tue_NV mới viết :
Chú ý : trước khi chạy Lisp, bạn phải joint các Arc và Pline thành 1 đối tượng kín
- Tải lisp
- 161146_ttt.lsp
Cách dùng
- Tải tệp 161146_ttt.lsp về máy.
- 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ẽ.
- Gõ lệnh TTT để chạy lisp.
Mã nguồn 161146_ttt.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/50052-y%C3%AAu-c%E1%BA%A7u-lip-t%C3%ADnh-kh%E1%BB%91i-l%C6%B0%E1%BB%A3ng-th%E1%BB%83-t%C3%ADch-v%E1%BA%ADt-li%E1%BB%87u/
(defun c:ttt(/ e1 e2 tile s1 s2 Res text)
(defun gb( / ss from to cur)
(setq frome (entlast)) ;; chon doi tuong cuoi cung truoc khi boundary
(command ".boundary" pause "") ;; boundary
(setq toe (entlast)) ;; chon doi tuong cuoi cung sau khi boundary
(setq cur frome ; khoi tao
ss (ssadd)
)
(while (not (eq cur toe)) ;; chon cac doi tuong tu frome den toe
(setq
cur (entnext cur)
ss (ssadd cur ss)
)
)
(sssetfirst ss ss) ;; highlight ket qua
ss
)
;Main
(princ "chon 1 diem trong hinh thu nhat") (setq e1 (gb))
(princ "chon 1 diem trong hinh thu hai") (setq e2 (gb))
(setq dis (getdist "\n Nhap chieu dai hoac Pick 2 diem tren man hinh lam chieu dai :"))
(or *tile* (setq *tile* 1.0))
(setq tile (getreal (strcat "\n Nhap he so ti le < " (rtos *tile* 2 3) " > ")))
(if tile (setq *tile* tile) (setq tile *tile*))
(Command "area" "o" e1)
(setq s1 (getvar "area"))
(Command "area" "o" e2)
(setq s2 (getvar "area"))
(command "erase" e1 e2 "")
(setq Res (* (/ (+ s1 s2) 2.0) dis tile tile tile))
(setq text (entget(car(entsel "\n pick Text thay the"))))
(entmod (subst (cons 1 (rtos Res 2 2)) (assoc 1 text) text))
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [yêu cầu] lip tính khối lượng thể tích vật liệu. Xem đúng bài viết #161146 để đọc hướng dẫn và trao đổi thêm.