Lisp rải taluy kiểu thủy lợi !
Quick code, không dùng cho SPline
(defun c:test(/ eLine curve dist pt i j p1) (vl-load-com) (defun eLine (p1 P isFull)(entmake (list (cons 0 "LINE")(cons 10 p1)(cons 11 (if isFull P (polar p1 (angle p1 P) (/ (distance p1 P) 2))))))) (if (and (setq curve (car(entsel "\nPath curve ;"))) (setq dist (getdist "\n D :")) (setq pt (getpoint "\n P:")) (setq i -2 j -1) ) (progn (while (setq p1 (vlax-curve-getPointAtDist curve (* (setq i (+ i 2)) dist))) (eLine p1 pt T)) (while (setq p1 (vlax-curve-getPointAtDist curve (* (setq j (+ j 2)) dist))) (eLine p1 pt nil)) ) ))
- Tải lisp
- 171474_test.lsp
Cách dùng
- Tải tệp 171474_test.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 TEST để chạy lisp.
Mã nguồn 171474_test.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/55750-y%C3%AAu-c%E1%BA%A7u-lisp-r%E1%BA%A3i-taluy-ki%E1%BB%83u-th%E1%BB%A7y-l%E1%BB%A3i/
(defun c:test(/ eLine curve dist pt i j p1)
(vl-load-com)
(defun eLine (p1 P isFull)(entmake (list (cons 0 "LINE")(cons 10 p1)(cons 11 (if isFull P (polar p1 (angle p1 P) (/ (distance p1 P) 2)))))))
(if
(and (setq curve (car(entsel "\nPath curve ;")))
(setq dist (getdist "\n D :"))
(setq pt (getpoint "\n P:"))
(setq i -2 j -1)
)
(progn
(while (setq p1 (vlax-curve-getPointAtDist curve (* (setq i (+ i 2)) dist))) (eLine p1 pt T))
(while (setq p1 (vlax-curve-getPointAtDist curve (* (setq j (+ j 2)) dist))) (eLine p1 pt nil))
)
))
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [yêu cầu] Lisp rải taluy kiểu thủy lợi !. Xem đúng bài viết #171474 để đọc hướng dẫn và trao đổi thêm.