mình muốn nhờ viết lisp tính diện tích cho cad 2007 hoặc cao hơn
mình có 1 lisp cũng khá hay nhưng không thỏa mãn tất cả các yêu cầu của bạn.
đây là lisp mình sưu tầm và có chỉnh sửa thêm
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=59486
(Defun c:DT()
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(command "osnap" "none")
(if (null am)(setq am "1"))
(Setq temp1 T)
(While temp1
(setq pt (strcat "\nHe so ("am") \<Chon diem>: "))
(Initget "h H")
(setq str (getpoint pt))
(Cond
((= str "h") (setq am (getstring (strcat"\nNhap he so <"am"> :"))))
((= str "H") (setq am (getstring (strcat"\nNhap he so <"am"> :"))))
(Progn
(Setq pt str)
(setq temp1 nil)
)
)
)
(setq s 0)
(progn
; (setq pt (getpoint "\n Chon diem: "))
(while pt
(setq entold (cdr (assoc 5 (entget (entlast)))))
(command "boundary" pt "")
(setq entnew (cdr (assoc 5 (entget (entlast)))))
(if (/= entold entnew)
(progn
(setq entnew (entget (entlast)))
(if (assoc 62 entnew)
(setq entnew (subst (cons 62 (+ 3 (cdr (assoc 62 entnew)))) (assoc 62 entnew) entnew))
(setq entnew (append entnew (list (cons 62 (+ 3 (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 entnew))))))))))
)
(entmod entnew)
(Command "area" "o" (entlast))
(setq s (+ s (getvar "area")))
(setq pt (getpoint "\n Chon diem: "))
(entdel (entlast))
)
(progn
(princ "chon diem sai")
(setq pt (getpoint "\n Chon diem: "))
)
)
)
)
(command "osnap" "intersection")
(setq am (atof am))
(setq s (* s am))
(setq point (getpoint "\n Chon diem ghi dien tich: "))
(setq th (getvar "textsize"))
(setq th (getstring (strcat "\nChieu cao chu <"(rtos th)"> :")))
;(princ "\nDien tich nhung vung vua chon la: "s)
(command "TEXT" point th 0 (rtos s 2 2))
(setq am (rtos am))
(setvar "MODEMACRO" "**CHUC BAN LAM VIEC HIEU QUA** TAILIEUKYTHUAT.COM")
(princ )
)
đây là lisp mình sưu tầm và có chỉnh sửa thêm
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=59486
(Defun c:DT()
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(command "osnap" "none")
(if (null am)(setq am "1"))
(Setq temp1 T)
(While temp1
(setq pt (strcat "\nHe so ("am") \<Chon diem>: "))
(Initget "h H")
(setq str (getpoint pt))
(Cond
((= str "h") (setq am (getstring (strcat"\nNhap he so <"am"> :"))))
((= str "H") (setq am (getstring (strcat"\nNhap he so <"am"> :"))))
(Progn
(Setq pt str)
(setq temp1 nil)
)
)
)
(setq s 0)
(progn
; (setq pt (getpoint "\n Chon diem: "))
(while pt
(setq entold (cdr (assoc 5 (entget (entlast)))))
(command "boundary" pt "")
(setq entnew (cdr (assoc 5 (entget (entlast)))))
(if (/= entold entnew)
(progn
(setq entnew (entget (entlast)))
(if (assoc 62 entnew)
(setq entnew (subst (cons 62 (+ 3 (cdr (assoc 62 entnew)))) (assoc 62 entnew) entnew))
(setq entnew (append entnew (list (cons 62 (+ 3 (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 entnew))))))))))
)
(entmod entnew)
(Command "area" "o" (entlast))
(setq s (+ s (getvar "area")))
(setq pt (getpoint "\n Chon diem: "))
(entdel (entlast))
)
(progn
(princ "chon diem sai")
(setq pt (getpoint "\n Chon diem: "))
)
)
)
)
(command "osnap" "intersection")
(setq am (atof am))
(setq s (* s am))
(setq point (getpoint "\n Chon diem ghi dien tich: "))
(setq th (getvar "textsize"))
(setq th (getstring (strcat "\nChieu cao chu <"(rtos th)"> :")))
;(princ "\nDien tich nhung vung vua chon la: "s)
(command "TEXT" point th 0 (rtos s 2 2))
(setq am (rtos am))
(setvar "MODEMACRO" "**CHUC BAN LAM VIEC HIEU QUA** TAILIEUKYTHUAT.COM")
(princ )
)
- Tải lisp
- 191416_dt.lsp
Cách dùng
- Tải tệp 191416_dt.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 DT để chạy lisp.
Mã nguồn 191416_dt.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/62129-nh%E1%BB%9D-vi%E1%BA%BFt-lisp-m%C3%ACnh-mu%E1%BB%91n-nh%E1%BB%9D-vi%E1%BA%BFt-lisp-t%C3%ADnh-di%E1%BB%87n-t%C3%ADch-cho-cad-2007-ho%E1%BA%B7c-cao-h%C6%A1n/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=59486
(Defun c:DT()
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(command "osnap" "none")
(if (null am)(setq am "1"))
(Setq temp1 T)
(While temp1
(setq pt (strcat "\nHe so ("am") \<Chon diem>: "))
(Initget "h H")
(setq str (getpoint pt))
(Cond
((= str "h") (setq am (getstring (strcat"\nNhap he so <"am"> :"))))
((= str "H") (setq am (getstring (strcat"\nNhap he so <"am"> :"))))
(Progn
(Setq pt str)
(setq temp1 nil)
)
)
)
(setq s 0)
(progn
; (setq pt (getpoint "\n Chon diem: "))
(while pt
(setq entold (cdr (assoc 5 (entget (entlast)))))
(command "boundary" pt "")
(setq entnew (cdr (assoc 5 (entget (entlast)))))
(if (/= entold entnew)
(progn
(setq entnew (entget (entlast)))
(if (assoc 62 entnew)
(setq entnew (subst (cons 62 (+ 3 (cdr (assoc 62 entnew)))) (assoc 62 entnew) entnew))
(setq entnew (append entnew (list (cons 62 (+ 3 (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 entnew))))))))))
)
(entmod entnew)
(Command "area" "o" (entlast))
(setq s (+ s (getvar "area")))
(setq pt (getpoint "\n Chon diem: "))
(entdel (entlast))
)
(progn
(princ "chon diem sai")
(setq pt (getpoint "\n Chon diem: "))
)
)
)
)
(command "osnap" "intersection")
(setq am (atof am))
(setq s (* s am))
(setq point (getpoint "\n Chon diem ghi dien tich: "))
(setq th (getvar "textsize"))
(setq th (getstring (strcat "\nChieu cao chu <"(rtos th)"> :")))
;(princ "\nDien tich nhung vung vua chon la: "s)
(command "TEXT" point th 0 (rtos s 2 2))
(setq am (rtos am))
(setvar "MODEMACRO" "**CHUC BAN LAM VIEC HIEU QUA** TAILIEUKYTHUAT.COM")
(princ )
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Nhờ viết Lisp] mình muốn nhờ viết lisp tính diện tích cho cad 2007 hoặc cao hơn. Xem đúng bài viết #191416 để đọc hướng dẫn và trao đổi thêm.