Jump to content

Lisp lệnh BAO trong chủ đề “Viết Lisp Tạo Đường Bao”

 

Quick code

(defun c:bao()
  (setq p (getpoint "pick diem :"))
  (command "._boundary" "A" "O" "R" "" p "")
  (Command "._region" "L" "")
  (setq el (entlast)) (redraw el 3)
  (while (setq p (getpoint "pick diem :"))
      (command "._boundary" p "")
      (Command "._region" "L" "")
    (command "._union" el "L" "")
    (setq el (entlast))
    (redraw el 3)
  )
)

Anh có thể bỏ bắt điểm được không. Vì ở đây mình chỉ cần pick vào vùng kín.

Với lại sau khi xong region nó cứ như là được chọn vậy anh, mặc dù nó có được đâu ạ.

Cách dùng

  1. Tải tệp 414885_bao.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 BAO để chạy lisp.

Mã nguồn 414885_bao.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/168447-vi%E1%BA%BFt-lisp-t%E1%BA%A1o-%C4%91%C6%B0%E1%BB%9Dng-bao/
(defun c:bao()
  (setq p (getpoint "pick diem :"))
  (command "._boundary" "A" "O" "R" "" p "")
  (Command "._region" "L" "")
  (setq el (entlast)) (redraw el 3)
  (while (setq p (getpoint "pick diem :"))
      (command "._boundary" p "")
      (Command "._region" "L" "")
    (command "._union" el "L" "")
    (setq el (entlast))
    (redraw el 3)
  )
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Viết Lisp Tạo Đường Bao. Xem đúng bài viết #414885 để đọc hướng dẫn và trao đổi thêm.

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