Lisp lệnh TDT trong chủ đề “Tính diện tích tạo nên từ những vùng giao nhau giữa 2 đường polyline”
Tính 2 loại diện tích nằm giữa 2 polyline đây :
- Tải lisp
- 121550_tdt.lsp
Cách dùng
- Tải tệp 121550_tdt.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 TDT để chạy lisp.
Mã nguồn 121550_tdt.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/28157-t%C3%ADnh-di%E1%BB%87n-t%C3%ADch-t%E1%BA%A1o-n%C3%AAn-t%E1%BB%AB-nh%E1%BB%AFng-v%C3%B9ng-giao-nhau-gi%E1%BB%AFa-2-%C4%91%C6%B0%E1%BB%9Dng-polyline/
;============================================================================!
;================================PFIEVXD-CADViet.com==============================
(Defun Dscon(TDlist gd1 gd2)
(Vl-remove-if '(lambda(x)(or(<=(car x)(car Gd1))(>=(car x)(car gd2)))) TDlist))
;---------------------------------------------------------------------------------
(Defun c:TDT(/ TDlist TDlist1 TDlist2 pl1 pl2 DT DT1 DT2
TDlist11 TDlist22 i gd1 gd2 gd3 gd4 )
(Setq Pl1 (Car(Entsel"\n Select First Pline :"))
Pl2 (Car(Entsel"\n Select Second Pline :"))
TDlist (Acet-geom-intersectwith Pl1 pl2 0)
TDlist1 (Acet-geom-vertex-list PL1)
TDlist2 (Acet-geom-vertex-list Pl2)
n (Length TDList)
i 0
DT1 0
DT2 0)
(While (< i (- n 1))
(Setq Gd1 (Nth i TDlist)
Gd2 (NTh (1+ i) TDlist)
TDlist11 (Dscon TDlist1 gd1 gd2)
TDlist22 (Dscon TDlist2 gd1 gd2)
TDlist3 (Append (list gd1) TDlist11 (list gd2) (Reverse TDlist22) (list gd1)))
(Acet-pline-make (list TDlist3))
(Command "AREA" "O" (Entlast))
(Setq DT(Getvar "AREA"))
(Command "ERASE" (Entlast)"")
;------------------------------------------------------------------------------
(Setq Midpoint(Acet-geom-midpoint Gd1 Gd2))
(Command "XLINE" "Ver" Midpoint "")
(Setq gd3 (Acet-geom-intersectwith (Entlast) Pl1 0)
gd4 (Acet-geom-intersectwith (Entlast) Pl2 0)
)
(If(>=(Cadr(Car gd3))(Cadr(Car gd4)))
(Setq DT1(+ DT1 DT))
(Setq DT2(+ DT2 DT))
)
(Command "ERASE" (Entlast)"")
(Setq i(1+ i))
)
(Princ (Strcat"\n Dien tich loai 1 = " (Rtos DT1 2 2)))
(Princ (Strcat"\n Dien tich loai 2 = " (Rtos DT2 2 2)))
(Princ))
;================================PFIEVXD-CADViet.com===============================!
Thảo luận gốc
Lisp được chia sẻ trong chủ đề Tính diện tích tạo nên từ những vùng giao nhau giữa 2 đường polyline. Xem đúng bài viết #121550 để đọc hướng dẫn và trao đổi thêm.