Jump to content

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

Ý mình là như vậy này: pick vào các hình A, B, C rồi tạo đường bao cho cho cả 3 hình ấy.

https://www.cadviet.com/upfiles/7/159384_duong_bao.dwg

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)
  )
)

Cách dùng

  1. Tải tệp 414853_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 414853_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 #414853 để đọc hướng dẫn và trao đổi thêm.

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