Lisp lệnh DTCD trong chủ đề “Viết lisp theo yêu cầu [phần 2]”
Của bạn đây. Đúng với file bạn up lên.
- Tải lisp
- 114710_dtcd.lsp
Cách dùng
- Tải tệp 114710_dtcd.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 DTCD để chạy lisp.
Mã nguồn 114710_dtcd.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/13203-vi%E1%BA%BFt-lisp-theo-y%C3%AAu-c%E1%BA%A7u-ph%E1%BA%A7n-2/?page=96
(defun c:dtcd ()
(setq dth (car (entsel "\nChon vung can tinh dien tich"))
pl (car (entsel "\nChon pline can tinh chieu dai"))
ob1 (vlax-ename->vla-object dth)
ob2 (vlax-ename->vla-object pl)
dientich (vla-get-area ob1)
chieudai (vla-get-length ob2)
blatt (car (entsel "\nChon block attribute"))
ent (entget blatt))
(if (= (cdr (assoc 66 ent)) 1)
(progn
(setq name1 (entnext blatt)
ent1 (entget name1))
(entmod (subst (cons 1 (rtos dientich 2 2)) (assoc 1 ent1) ent1))
(entupd blatt)
(setq name2 (entnext name1)
ent2 (entget name2))
(entmod (subst (cons 1 (rtos chieudai 2 2)) (assoc 1 ent2) ent2))
(entupd blatt)
)
(alert "doi tuong duoc chon khong phai la block attibute")
)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Viết lisp theo yêu cầu [phần 2]. Xem đúng bài viết #114710 để đọc hướng dẫn và trao đổi thêm.