Jump to content

Lisp lệnh THKL trong chủ đề “Nhờ viết lisp thông kê giá trị trong block ATT”

 

Hề hề hề,

Bậu down lại lisp này nhé

(DEFUN C:THKL (/ ssl dtl dtt e1 e2 e3 ltt et goc)
(setq ssl (acet-ss-to-list (ssget (list (cons 0 "insert") (cons 66 1)))))
(while (setq e1 (car (nentsel "\n Chon thuoc tinh loc")))
(setq dtl (cdr (assoc 1 (entget e1))))
(setq goc 0)
(setq dtt (cdr (assoc 2 (entget (setq e2 (car (nentsel "\n Chon thuoc tinh can tinh")))))))
(setq ltt (list))
(foreach e ssl
    (setq et (entnext e))
    (while (/= (cdr (assoc 0 (entget et))) "SEQEND")
            (if (and (= (cdr (assoc 1 (entget et))) dtl) (= (cdr (assoc 2 (entget et))) (cdr (assoc 2 (entget e1)))))                          
                (setq ltt (append ltt (list e)))
            )
            (setq et (entnext et))
    )
)
(foreach e ltt
     (setq et (entnext e))
     (while (/= (cdr (assoc 0 (entget et))) "SEQEND")
              (if (= (cdr (assoc  2 (entget et))) dtt)
                  (setq goc (+ goc (atof (cdr (assoc 1 (entget et))))))
              )
              (setq et (entnext et))
      )
)
(entmod (subst (cons 1 (rtos goc 2 2)) (assoc 1 (entget (setq e3 (car (nentsel "\n Chon text can thay the"))))) (entget e3)))
(entupd e3)
)
)

Oke, cảm ơn bạn nhiều nhé, bạn sửa giúp mình cái lisp của bạn bach_gia luôn y!!

Cách dùng

  1. Tải tệp 345979_thkl.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 THKL để chạy lisp.

Mã nguồn 345979_thkl.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/126869-nh%E1%BB%9D-vi%E1%BA%BFt-lisp-th%C3%B4ng-k%C3%AA-gi%C3%A1-tr%E1%BB%8B-trong-block-att/
(DEFUN C:THKL (/ ssl dtl dtt e1 e2 e3 ltt et goc)
(setq ssl (acet-ss-to-list (ssget (list (cons 0 "insert") (cons 66 1)))))
(while (setq e1 (car (nentsel "\n Chon thuoc tinh loc")))
(setq dtl (cdr (assoc 1 (entget e1))))
(setq goc 0)
(setq dtt (cdr (assoc 2 (entget (setq e2 (car (nentsel "\n Chon thuoc tinh can tinh")))))))
(setq ltt (list))
(foreach e ssl
    (setq et (entnext e))
    (while (/= (cdr (assoc 0 (entget et))) "SEQEND")
            (if (and (= (cdr (assoc 1 (entget et))) dtl) (= (cdr (assoc 2 (entget et))) (cdr (assoc 2 (entget e1)))))                          
                (setq ltt (append ltt (list e)))
            )
            (setq et (entnext et))
    )
)
(foreach e ltt
     (setq et (entnext e))
     (while (/= (cdr (assoc 0 (entget et))) "SEQEND")
              (if (= (cdr (assoc  2 (entget et))) dtt)
                  (setq goc (+ goc (atof (cdr (assoc 1 (entget et))))))
              )
              (setq et (entnext et))
      )
)
(entmod (subst (cons 1 (rtos goc 2 2)) (assoc 1 (entget (setq e3 (car (nentsel "\n Chon text can thay the"))))) (entget e3)))
(entupd e3)
)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Nhờ viết lisp thông kê giá trị trong block ATT. Xem đúng bài viết #345979 để đọc hướng dẫn và trao đổi thêm.

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