Lisp tạo viewport từ khung chọn bên model.
Bạn Tùng ơi theo ý kiến của nhoc thì thế này vì việc chọn khổ giấy liên quan đến việc chọn vùng nên nhoc nghĩ mình cứ để vậy thui, nhoc cũng ko pit sữa ^^, chờ pac KangKung giúp vậy
, nhoc để nguyên phần chọn khổ nhé
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=68723&pid=226065&st=0&#entry226065
;========LISP TAO VIEWPORT TREN LAYOUT BANG CACH CHON O MODEL========
(defun C:mtl(/ taphop soluong ten size i index oldos)
(command "UNDO" "BE")
(setq oldos (getvar "osmode"))
(setvar "OSMODE" 0)
(setq taphop(ssget))
(setq soluong (sslength taphop))
(setq size(getstring "\n Kho giay in A0/A1/A2/A3/A4? < A3 >: "))
(if (= size nil) (setq size A3))
(setq ten (getstring 1 "\n Nhap ten layout:"))
(setq index 0)
(setq i 0)
(while (< index soluong)
(setq i(1+ i))
(setq khung(ssname taphop index))
(setq lst(acet-geom-vertex-list khung))
(command "COPYCLIP" khung "")
(command "layout" "n" (strcat "layout" (rtos i 2 0)))
(command "LAYOUT" "N" (strcat ten (rtos i 2 0)))
(command "LAYOUT" "S" (strcat ten (rtos i 2 0)))
(command "layout" "d" "layout1" "")
(command "layout" "d" "layout2" "")
(command "layout" "d" "layout3" "")
(command "ERASE" "ALL" "")
(command "PASTECLIP" "0,0")
(command "MVIEW" "O" (entlast))
(command "MSPACE")
(command "ZOOM" (nth 0 lst) (nth 2 lst))
(command "PSPACE")
(command "ZOOM" "E")
(command "PLOT" "Y" "" "" size "M" "L" "N" "W" "0,0" (list (abs(- (car (nth 2 lst)) (car (nth 0 lst)))) (abs(- (cadr (nth 2 lst)) (cadr (nth 0 lst))))) "F" "" "Y" "" "Y" "N" "N" "N" "N" "Y" "N")
(command "MODEL")
(setq index (+ index 1))
)
(command "UNDO" "END")
(setvar "OSMODE" oldos)
(princ)
)
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=68723&pid=226065&st=0&#entry226065
;========LISP TAO VIEWPORT TREN LAYOUT BANG CACH CHON O MODEL========
(defun C:mtl(/ taphop soluong ten size i index oldos)
(command "UNDO" "BE")
(setq oldos (getvar "osmode"))
(setvar "OSMODE" 0)
(setq taphop(ssget))
(setq soluong (sslength taphop))
(setq size(getstring "\n Kho giay in A0/A1/A2/A3/A4? < A3 >: "))
(if (= size nil) (setq size A3))
(setq ten (getstring 1 "\n Nhap ten layout:"))
(setq index 0)
(setq i 0)
(while (< index soluong)
(setq i(1+ i))
(setq khung(ssname taphop index))
(setq lst(acet-geom-vertex-list khung))
(command "COPYCLIP" khung "")
(command "layout" "n" (strcat "layout" (rtos i 2 0)))
(command "LAYOUT" "N" (strcat ten (rtos i 2 0)))
(command "LAYOUT" "S" (strcat ten (rtos i 2 0)))
(command "layout" "d" "layout1" "")
(command "layout" "d" "layout2" "")
(command "layout" "d" "layout3" "")
(command "ERASE" "ALL" "")
(command "PASTECLIP" "0,0")
(command "MVIEW" "O" (entlast))
(command "MSPACE")
(command "ZOOM" (nth 0 lst) (nth 2 lst))
(command "PSPACE")
(command "ZOOM" "E")
(command "PLOT" "Y" "" "" size "M" "L" "N" "W" "0,0" (list (abs(- (car (nth 2 lst)) (car (nth 0 lst)))) (abs(- (cadr (nth 2 lst)) (cadr (nth 0 lst))))) "F" "" "Y" "" "Y" "N" "N" "N" "N" "Y" "N")
(command "MODEL")
(setq index (+ index 1))
)
(command "UNDO" "END")
(setvar "OSMODE" oldos)
(princ)
)
- Tải lisp
- 226072_mtl.lsp
Cách dùng
- Tải tệp 226072_mtl.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 MTL để chạy lisp.
Mã nguồn 226072_mtl.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/68723-y%C3%AAu-c%E1%BA%A7u-lisp-t%E1%BA%A1o-viewport-t%E1%BB%AB-khung-ch%E1%BB%8Dn-b%C3%AAn-model/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=68723&pid=226065&st=0entry226065
;========LISP TAO VIEWPORT TREN LAYOUT BANG CACH CHON O MODEL========
(defun C:mtl(/ taphop soluong ten size i index oldos)
(command "UNDO" "BE")
(setq oldos (getvar "osmode"))
(setvar "OSMODE" 0)
(setq taphop(ssget))
(setq soluong (sslength taphop))
(setq size(getstring "\n Kho giay in A0/A1/A2/A3/A4? < A3 >: "))
(if (= size nil) (setq size A3))
(setq ten (getstring 1 "\n Nhap ten layout:"))
(setq index 0)
(setq i 0)
(while (< index soluong)
(setq i(1+ i))
(setq khung(ssname taphop index))
(setq lst(acet-geom-vertex-list khung))
(command "COPYCLIP" khung "")
(command "layout" "n" (strcat "layout" (rtos i 2 0)))
(command "LAYOUT" "N" (strcat ten (rtos i 2 0)))
(command "LAYOUT" "S" (strcat ten (rtos i 2 0)))
(command "layout" "d" "layout1" "")
(command "layout" "d" "layout2" "")
(command "layout" "d" "layout3" "")
(command "ERASE" "ALL" "")
(command "PASTECLIP" "0,0")
(command "MVIEW" "O" (entlast))
(command "MSPACE")
(command "ZOOM" (nth 0 lst) (nth 2 lst))
(command "PSPACE")
(command "ZOOM" "E")
(command "PLOT" "Y" "" "" size "M" "L" "N" "W" "0,0" (list (abs(- (car (nth 2 lst)) (car (nth 0 lst)))) (abs(- (cadr (nth 2 lst)) (cadr (nth 0 lst))))) "F" "" "Y" "" "Y" "N" "N" "N" "N" "Y" "N")
(command "MODEL")
(setq index (+ index 1))
)
(command "UNDO" "END")
(setvar "OSMODE" oldos)
(princ)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu cầu] Lisp tạo viewport từ khung chọn bên model.. Xem đúng bài viết #226072 để đọc hướng dẫn và trao đổi thêm.