Lisp lệnh MTL trong chủ đề “[Yêu cầu] Lisp tạo viewport từ khung chọn bên model.”
Bạn anhbkhcm spam ghê thế, như nói trên nhoc mới tập tềnh về lsp thui, việc xuất ra trong 1 layout nhoc có thể sữa đc nhưng cách nhau 50m thì nhoc chịu ^^, mà bạn có để ý ko, layout là cách nói hiển thị trên trang giấy mà mỗi khung cách nhau 50m thì tờ giấy phải dài bao nhiu mới đủ đây 
- Nếu cách nhau 50mm = 5cm thì có thể đc or 500mm = 50 cm cũng có thể đc nhưng in ra cũng tốn giấy ah ^^
-thôi thì thế này nhoc chỉ giúp bạn sữa đc ra trong 1 layout thui còn lại bạn tự xử hen
, thông cảm khả năng giới hạn
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=68723&pid=225475&st=0&#entry225475
;========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 ten (getstring 1 "\n Nhap ten layout:"))
(setq index 0)
(setq i 0)
(while (< index soluong)
(setq i 1)
(setq khung(ssname taphop index))
(setq lst(acet-geom-vertex-list khung))
(command "COPYCLIP" khung "")
(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)
)
- Nếu cách nhau 50mm = 5cm thì có thể đc or 500mm = 50 cm cũng có thể đc nhưng in ra cũng tốn giấy ah ^^
-thôi thì thế này nhoc chỉ giúp bạn sữa đc ra trong 1 layout thui còn lại bạn tự xử hen
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=68723&pid=225475&st=0&#entry225475
;========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 ten (getstring 1 "\n Nhap ten layout:"))
(setq index 0)
(setq i 0)
(while (< index soluong)
(setq i 1)
(setq khung(ssname taphop index))
(setq lst(acet-geom-vertex-list khung))
(command "COPYCLIP" khung "")
(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
- 226071_mtl.lsp
Cách dùng
- Tải tệp 226071_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 226071_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=225475&st=0entry225475
;========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 ten (getstring 1 "\n Nhap ten layout:"))
(setq index 0)
(setq i 0)
(while (< index soluong)
(setq i 1)
(setq khung(ssname taphop index))
(setq lst(acet-geom-vertex-list khung))
(command "COPYCLIP" khung "")
(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 #226071 để đọc hướng dẫn và trao đổi thêm.