lisp tính tổng các số (VERY EASY)
Lisp đầu :
;free lisp from CadViet.com @ketxu (defun dxf (dxf ent) (cdr (assoc dxf (entget ent)))) (defun wtxt_l(txt p / sty d h1 h2 wf h) ;;;Write txt on graphic screen at p (setq sty (getvar "textstyle") d (tblsearch "style" sty) h1 (cdr (assoc 40 d)) h2 (cdr (assoc 42 d)) wf (cdr (assoc 41 d))) (if (> h1 0) (setq h h1) (setq h h2)) (entmake (list (cons 0 "TEXT") (cons 7 sty) (cons 40 h) (cons 41 wf)(cons 72 1)(cons 11 p) (cons 1 txt) (cons 10 p)))) (defun c:ct(/ sum ssc sst) (setq ssc (acet-ss-to-list (ssget '((0 . "*TEXT")))) sst (acet-ss-to-list (ssget '((0 . "*TEXT")))) sum 0) (foreach x ssc (setq sum (+ sum (atof (dxf 1 x)))) ) (foreach x sst (setq sum (- sum (atof (dxf 1 x)))) ) (wtxt_l (rtos sum 2 2) (getpoint "\n Diem chen ket qua")) )
Tuyệt vời. cảm ơn bạn. Qua nhiều lisp hay !!!
- Tải lisp
- 158743_ct.lsp
Cách dùng
- Tải tệp 158743_ct.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 CT để chạy lisp.
Mã nguồn 158743_ct.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/36599-y%C3%AAu-c%E1%BA%A7u-lisp-t%C3%ADnh-t%E1%BB%95ng-c%C3%A1c-s%E1%BB%91-very-easy/
;free lisp from CadViet.com @ketxu
(defun dxf (dxf ent) (cdr (assoc dxf (entget ent))))
(defun wtxt_l(txt p / sty d h1 h2 wf h) ;;;Write txt on graphic screen at p
(setq sty (getvar "textstyle")
d (tblsearch "style" sty)
h1 (cdr (assoc 40 d))
h2 (cdr (assoc 42 d))
wf (cdr (assoc 41 d)))
(if (> h1 0) (setq h h1) (setq h h2))
(entmake (list (cons 0 "TEXT") (cons 7 sty) (cons 40 h) (cons 41 wf)(cons 72 1)(cons 11 p) (cons 1 txt) (cons 10 p))))
(defun c:ct(/ sum ssc sst)
(setq ssc (acet-ss-to-list (ssget '((0 . "*TEXT"))))
sst (acet-ss-to-list (ssget '((0 . "*TEXT"))))
sum 0)
(foreach x ssc
(setq sum (+ sum (atof (dxf 1 x))))
)
(foreach x sst
(setq sum (- sum (atof (dxf 1 x))))
)
(wtxt_l (rtos sum 2 2) (getpoint "\n Diem chen ket qua"))
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu cầu] lisp tính tổng các số (VERY EASY). Xem đúng bài viết #158743 để đọc hướng dẫn và trao đổi thêm.