Copy theo đối tượng có sẵn
Lại vọc bậy vậy
Lưu ý:
- Cad có cài bộ express
- Các thao tác chọn trắc ngang chuẩn / trắc ngang cần paste thực ra la chỉ cần chon được 2D polyline "PLINEMATPHAI" là được
- Tất nhiên là lisp chỉ chậy được trên BV tương tự BV mẫu, dạng khác thì ko chắc :D :D :D
;;;Lisp co cong nang tuong tu lenh copy thiet ke trong nova
(defun c:CPTK( / BASE_POINT LST_VA OLD SS SS1 SS2)
(vl-load-com)
(setq lst_va '("osmode" "cmdecho"))
(setq old (mapcar 'getvar lst_va))
(mapcar 'setvar lst_va '(0 0))
(prompt "\nChon doi tuong can copy:")
(setq ss (ssget))
(prompt "\nChon trac ngang lam chuan:")
;(setq ss1 (ssget '((8 . "PLINEMATPHAI,PLINEMATTRAI"))))
(setq ss1 (ssget '((8 . "PLINEMATPHAI"))))
(prompt "\nChon trac ngang can paste:")
;(setq ss2 (ssget '((8 . "PLINEMATPHAI,PLINEMATTRAI"))))
(setq ss2 (ssget '((8 . "PLINEMATPHAI"))))
(if (and ss ss1 ss2)
(progn
(setq base_point (car (acet-geom-vertex-list (ssname ss1 0)))
ss2 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss2))))
(foreach elem ss2
(vl-cmdf ".copy" ss "" base_point (car (acet-geom-vertex-list elem)))
)
(princ (strcat "\nDa copy doi tuong ra " (itoa (length ss2)) " ban!"))
)
(princ "\nXay ra loi roi, nghien cuu lai!")
)
;;xong tra ve:
(mapcar 'setvar lst_va old)
(princ)
)
- Tải lisp
- 424346_cptk.lsp
Cách dùng
- Tải tệp 424346_cptk.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 CPTK để chạy lisp.
Mã nguồn 424346_cptk.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/171659-xin-lisp-copy-theo-%C4%91%E1%BB%91i-t%C6%B0%E1%BB%A3ng-c%C3%B3-s%E1%BA%B5n/
;;;Lisp co cong nang tuong tu lenh copy thiet ke trong nova
(defun c:CPTK( / BASE_POINT LST_VA OLD SS SS1 SS2)
(vl-load-com)
(setq lst_va '("osmode" "cmdecho"))
(setq old (mapcar 'getvar lst_va))
(mapcar 'setvar lst_va '(0 0))
(prompt "\nChon doi tuong can copy:")
(setq ss (ssget))
(prompt "\nChon trac ngang lam chuan:")
;(setq ss1 (ssget '((8 . "PLINEMATPHAI,PLINEMATTRAI"))))
(setq ss1 (ssget '((8 . "PLINEMATPHAI"))))
(prompt "\nChon trac ngang can paste:")
;(setq ss2 (ssget '((8 . "PLINEMATPHAI,PLINEMATTRAI"))))
(setq ss2 (ssget '((8 . "PLINEMATPHAI"))))
(if (and ss ss1 ss2)
(progn
(setq base_point (car (acet-geom-vertex-list (ssname ss1 0)))
ss2 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss2))))
(foreach elem ss2
(vl-cmdf ".copy" ss "" base_point (car (acet-geom-vertex-list elem)))
)
(princ (strcat "\nDa copy doi tuong ra " (itoa (length ss2)) " ban!"))
)
(princ "\nXay ra loi roi, nghien cuu lai!")
)
;;xong tra ve:
(mapcar 'setvar lst_va old)
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Xin lisp] Copy theo đối tượng có sẵn. Xem đúng bài viết #424346 để đọc hướng dẫn và trao đổi thêm.