lisp-Làm thế nào để tìm số đối tượng sinh ra bởi lệnh Boundary
Mình xuống dòng hộ bạn cái lisp bạn quote, và nhìn code chẳng thấy chỗ nào liên quan đến diện tích cả :)
;; free lisp from cadviet.com ;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/9764-da-xong-lisp-lam-the-nao-de-tim-so-doi-tuong-sinh-ra-boi-lenh-boundary/ (defun c:gb(/ po frome toe cur ss st LA CA) (setq po (getpoint "\n Pick diem :")) (setq frome (entlast)) ;; chon doi tuong cuoi cung truoc khi boundary (command "boundary" "A" "O" "R" "" po "") ;; Region (setq toe (entlast)) ;; chon doi tuong cuoi cung sau khi Region (setq cur frome ; khoi taoss ss (ssadd)) (while (not (eq cur toe)) ;; chon cac doi tuong tu frome den toe (setqcur (entnext cur)ss (ssadd cur ss))) (setq st (ss2ent ss)) (setq LA (car st)) (setq CA (ssdel LA ss)) (Command "subtract" LA "" CA "") (princ)) ;; (defun ss2ent (ss / sodt index lstent)(setqsodt (if ss (sslength ss) 0)index 0)(repeat sodt(setq ent (ssname ss index)index (1+ index)lstent (cons ent lstent)))(reverse lstent))
Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.
Cách dùng
- Chép mã nguồn, lưu thành tệp 305809_gb.lsp.
- 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 GB để chạy lisp.
Mã nguồn 305809_gb.lsp (trích từ bài viết gốc)
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/9764-da-xong-lisp-lam-the-nao-de-tim-so-doi-tuong-sinh-ra-boi-lenh-boundary/
(defun c:gb(/ po frome toe cur ss st LA CA)
(setq po (getpoint "\n Pick diem :"))
(setq frome (entlast)) ;; chon doi tuong cuoi cung truoc khi boundary
(command "boundary" "A" "O" "R" "" po "") ;; Region
(setq toe (entlast)) ;; chon doi tuong cuoi cung sau khi Region
(setq cur frome ; khoi taoss
ss (ssadd))
(while (not (eq cur toe)) ;; chon cac doi tuong tu frome den toe
(setqcur (entnext cur)ss (ssadd cur ss)))
(setq st (ss2ent ss))
(setq LA (car st))
(setq CA (ssdel LA ss))
(Command "subtract" LA "" CA "")
(princ))
;;
(defun ss2ent (ss / sodt index lstent)(setqsodt (if ss (sslength ss) 0)index 0)(repeat sodt(setq ent (ssname ss index)index (1+ index)lstent (cons ent lstent)))(reverse lstent))Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Đã xong] lisp-Làm thế nào để tìm số đối tượng sinh ra bởi lệnh Boundary. Xem đúng bài viết #305809 để đọc hướng dẫn và trao đổi thêm.