Lisp tạo viewport từ khung chọn bên model.
sax lạ vậy bạn tải lại bản này xem ngắn gọn hơn xíu chắc ko lỗi ^^
;========LISP TAO VIEWPORT TREN LAYOUT BANG CACH CHON O MODEL======== ;===============REV3===================== (defun C:mtl(/ taphop soluong ten khung tyle oldos i lst X index) (command "UNDO" "BE") (setq oldos (getvar "osmode")) (setvar "OSMODE" 0) (setq taphop(ssget)) (setq Tyle (getreal (strcat "\n Ty le 1/ <1000>: "))) (if (= Tyle nil) (setq Tyle 1000)) (setq soluong (sslength taphop)) (setq index 0) (setq i 0) (setq ten (getstring "\n Nhap ten layout:")) (command "layout" "N" ten) (command "LAYOUT" "S" ten) (command "ERASE" "ALL" "") (command "MODEL") (setq X 0) (command "ZOOM" "E") (while (< index soluong) (setq i(1+ i)) (setq khung(ssname taphop index)) (setq lst(acet-geom-vertex-list khung)) (command "COPYCLIP" khung "") (command "LAYOUT" "S" ten) (command "PASTECLIP" (list X 0)) (command "SCALE" (entlast) "" (list X 0) (/ 1000 tyle)) (command "MVIEW" "O" (entlast)) (command "MSPACE") (command "ZOOM" (nth 0 lst) (nth 2 lst)) (command "PSPACE") (command "Mview" "L" "on" (entlast) "") (setq X(+ X 50 (/ (abs(- (car (nth 2 lst)) (car (nth 0 lst)))) (/ tyle 1000)))) (command "ZOOM" "W" (list 0 0) (list (+ X 100) 0)) (setq index (+ index 1)) ) (command "MODEL") (command "UNDO" "END") (setvar "OSMODE" oldos) (princ) )
Hay quá Bạn ơi. Bạn Thật siêu sao. Cảm ơn Bạn Rất rất nhiều. trên forum mình vãn còn một yêu cầu viết lisp ghi chú điểm. bạn xem giúp mình với.
- Tải lisp
- 226113_mtl.lsp
Cách dùng
- Tải tệp 226113_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 226113_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/?page=2
;========LISP TAO VIEWPORT TREN LAYOUT BANG CACH CHON O MODEL========
;===============REV3=====================
(defun C:mtl(/ taphop soluong ten khung tyle oldos i lst X index)
(command "UNDO" "BE")
(setq oldos (getvar "osmode"))
(setvar "OSMODE" 0)
(setq taphop(ssget))
(setq Tyle (getreal (strcat "\n Ty le 1/ <1000>: ")))
(if (= Tyle nil) (setq Tyle 1000))
(setq soluong (sslength taphop))
(setq index 0)
(setq i 0)
(setq ten (getstring "\n Nhap ten layout:"))
(command "layout" "N" ten)
(command "LAYOUT" "S" ten)
(command "ERASE" "ALL" "")
(command "MODEL")
(setq X 0)
(command "ZOOM" "E")
(while (< index soluong)
(setq i(1+ i))
(setq khung(ssname taphop index))
(setq lst(acet-geom-vertex-list khung))
(command "COPYCLIP" khung "")
(command "LAYOUT" "S" ten)
(command "PASTECLIP" (list X 0))
(command "SCALE" (entlast) "" (list X 0) (/ 1000 tyle))
(command "MVIEW" "O" (entlast))
(command "MSPACE")
(command "ZOOM" (nth 0 lst) (nth 2 lst))
(command "PSPACE")
(command "Mview" "L" "on" (entlast) "")
(setq X(+ X 50 (/ (abs(- (car (nth 2 lst)) (car (nth 0 lst)))) (/ tyle 1000))))
(command "ZOOM" "W" (list 0 0) (list (+ X 100) 0))
(setq index (+ index 1))
)
(command "MODEL")
(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 #226113 để đọc hướng dẫn và trao đổi thêm.