Jump to content

Lisp lệnh WPO trong chủ đề “dùng lệnh wipeout cho ellipse”

Vẽ Wipeout đường tròn bằng Polygon cạnh 300 đây, muốn hình vuông thì cạnh = 4 :)

(defun C:WPO (/ res cp pt oldos)
       (command "undo" "be")
(setq oldos (getvar "osmode"))
  (setq defres (if defres defres "300"))
  (setq res (getstring (strcat "\nEnter Resolution <"defres">: ")))
  (if (> (strlen res) 0) (setq defres res) (setq res defres))
  (setq cp (getpoint "\nPick Center Point: "))
  (setq pt (getpoint cp "\nPick Point: "))
  (setvar "osmode" 0) 
(initget "I C")
(setq sel (getkword "\nV\U+1EBD \U+0111a gi\U+00E1c n\U+1ED9i ti\U+1EBFp (I) hay ngo\U+1EA1i ti\U+1EBFp (C) v\U+1EDBi \U+0111\U+01B0\U+1EDDng tr\U+00F2n ? <C> :"))
(if (= sel "C")
 (command "polygon" res cp "C" pt)
 (command "polygon" res cp "I" pt)
)
  (command "wipeout" "polyline" "last" "yes")
(setvar "osmode" oldos)
(command "undo" "e")
  (princ))

Cách dùng

  1. Tải tệp 304557_wpo.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 WPO để chạy lisp.

Mã nguồn 304557_wpo.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/107078-d%C3%B9ng-l%E1%BB%87nh-wipeout-cho-ellipse/
(defun C:WPO (/ res cp pt oldos)
       (command "undo" "be")
(setq oldos (getvar "osmode"))
  (setq defres (if defres defres "300"))
  (setq res (getstring (strcat "\nEnter Resolution <"defres">: ")))
  (if (> (strlen res) 0) (setq defres res) (setq res defres))
  (setq cp (getpoint "\nPick Center Point: "))
  (setq pt (getpoint cp "\nPick Point: "))
  (setvar "osmode" 0) 
(initget "I C")
(setq sel (getkword "\nV\U+1EBD \U+0111a gi\U+00E1c n\U+1ED9i ti\U+1EBFp (I) hay ngo\U+1EA1i ti\U+1EBFp (C) v\U+1EDBi \U+0111\U+01B0\U+1EDDng tr\U+00F2n [i/C]? <C> :"))
(if (= sel "C")
 (command "polygon" res cp "C" pt)
 (command "polygon" res cp "I" pt)
)
  (command "wipeout" "polyline" "last" "yes")
(setvar "osmode" oldos)
(command "undo" "e")
  (princ))

Thảo luận gốc

Lisp được chia sẻ trong chủ đề dùng lệnh wipeout cho ellipse. Xem đúng bài viết #304557 để đọc hướng dẫn và trao đổi thêm.

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