Lisp rải đối tượng theo đơờng dẩn.
Em có lisp sau rải chấm hatch tròn tại các điểm endpoint của đối tượng. Bây giờ em muốn cải tiến lisp trên 1 chút là cho phép chọn 1 text đi kèm và cũng rải tăng dần tại endpoint theo bước +1. Nhờ các bác giúp đỡ ạ:
;; free lisp from cadviet.com ;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/73545-nho-cac-bac-sua-lisp-copy-doi-tuong-toi-nhieu-duong-polyline-cho-truoc/ (vl-load-com) (defun GetVer (e / i L) (setq i 0 L nil) (repeat (fix (+ (vlax-curve-getEndParam e) 1)) (setq L (append L (list (vlax-curve-getPointAtParam e i)))) (setq i (1+ i)) ) L ) (defun C:ttt(/ ss_rai pt_rai ss n e lstPt x) (princ "\nChon doi tuong muon rai") (setq ss_rai (ssget)) (setq pt_rai (getpoint "\nChon diem chen")) (princ "\nChon doi tuong duong dan") (setq ss (ssget (list (cons 0 "*POLYLINE")))) (repeat (setq n (sslength ss)) (setq e (ssname ss (setq n (1- n)))) (setq lstPt (GetVer e)) (foreach x lstPt (command "copy" ss_rai "" pt_rai x)) ) (princ) )
- Tải lisp
- 271653_ttt.lsp
Cách dùng
- Tải tệp 271653_ttt.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 TTT để chạy lisp.
Mã nguồn 271653_ttt.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/42771-%C4%91%C3%A3-xong-lisp-r%E1%BA%A3i-%C4%91%E1%BB%91i-t%C6%B0%E1%BB%A3ng-theo-%C4%91%C6%A1%E1%BB%9Dng-d%E1%BA%A9n/?page=4
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/73545-nho-cac-bac-sua-lisp-copy-doi-tuong-toi-nhieu-duong-polyline-cho-truoc/
(vl-load-com)
(defun GetVer (e / i L)
(setq i 0 L nil)
(repeat (fix (+ (vlax-curve-getEndParam e) 1))
(setq L (append L (list (vlax-curve-getPointAtParam e i))))
(setq i (1+ i))
)
L
)
(defun C:ttt(/ ss_rai pt_rai ss n e lstPt x)
(princ "\nChon doi tuong muon rai")
(setq ss_rai (ssget))
(setq pt_rai (getpoint "\nChon diem chen"))
(princ "\nChon doi tuong duong dan")
(setq ss (ssget (list (cons 0 "*POLYLINE"))))
(repeat (setq n (sslength ss))
(setq e (ssname ss (setq n (1- n))))
(setq lstPt (GetVer e))
(foreach x lstPt (command "copy" ss_rai "" pt_rai x))
)
(princ)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Đã xong] Lisp rải đối tượng theo đơờng dẩn.. Xem đúng bài viết #271653 để đọc hướng dẫn và trao đổi thêm.