Lisp rải taluy kiểu thủy lợi !
Em đồng ý, dù ai viết về vấn đề dù nhỏ nhất cũng cần nhìn nhận mọi khía cạnh điều mình hỏi. Lần này hay không bằng hên nên chẳng may viết đúng ý bạn hanam1210, e cũng quên béng mất là các đường nó không bằng nhau, ngại quá ^^
Bạn nhìn theo cái này, cần thay chỗ nào mình đều ghi chú rồi tự sửa nhé
(defun c:tlt(/ eLine curve pt i j len dsttmp) (vl-load-com) (or #dist (setq #dist 10)) ; 10 = Khoang cach mac dinh (setq #dist (cond ((getdist (strcat "\n D <" (vl-princ-to-string #dist) " > :")))(#dist))) (defun eLine (p1 P isFull / p2 col) (if isFull (setq p2 P col 1) ;1 = Mau cua Line full (setq p2 (polar p1 (angle p1 P) (/ (distance p1 P) 2)) col 8) ; 8 = Mau cua Line nua ) (entmake (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2)(cons 62 col) (cons 8 "0") ;0 = Layer cua Duong Taluy ) ) ) ;;Doan duoi nay khong can de y (while (and (setq curve (car(entsel "\nPath curve :"))) (wcmatch (cdadr (entget curve)) "*LINE,ARC") (setq pt (getpoint "\n P :")) (setq i -2 j -1 len (vlax-curve-getDistAtParam curve (vlax-curve-getEndParam curve))) ) (progn (while (< (setq dsttmp (* (setq i (+ i 2)) #dist)) len) (eLine (vlax-curve-getPointAtDist curve dsttmp) pt T)) (while (< (setq dsttmp (* (setq j (+ j 2)) #dist)) len) (eLine (vlax-curve-getPointAtDist curve dsttmp) pt nil)) ) ))
Cảm ơn bác KETXU nhé. Lisp chạy rất chuẩn. Thế là diễn đàn mình có thêm một kiểu rải taluy nữa. Kiểu rải này đúng ở các góc của đường đắp. Hoặc ở phần giao của đường nhánh với đường chính ( Đắp )
- Tải lisp
- 171560_tlt.lsp
Cách dùng
- Tải tệp 171560_tlt.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 TLT để chạy lisp.
Mã nguồn 171560_tlt.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:tlt(/ eLine curve pt i j len dsttmp)
(vl-load-com)
(or #dist (setq #dist 10)) ; 10 = Khoang cach mac dinh
(setq #dist (cond ((getdist (strcat "\n D <" (vl-princ-to-string #dist) " > :")))(#dist)))
(defun eLine (p1 P isFull / p2 col)
(if isFull
(setq p2 P col 1) ;1 = Mau cua Line full
(setq p2 (polar p1 (angle p1 P) (/ (distance p1 P) 2)) col 8) ; 8 = Mau cua Line nua
)
(entmake
(list (cons 0 "LINE")(cons 10 p1)
(cons 11 p2)(cons 62 col)
(cons 8 "0") ;0 = Layer cua Duong Taluy
)
)
)
;;Doan duoi nay khong can de y
(while
(and
(setq curve (car(entsel "\nPath curve :")))
(wcmatch (cdadr (entget curve)) "*LINE,ARC")
(setq pt (getpoint "\n P :"))
(setq i -2 j -1 len (vlax-curve-getDistAtParam curve (vlax-curve-getEndParam curve)))
)
(progn
(while (< (setq dsttmp (* (setq i (+ i 2)) #dist)) len) (eLine (vlax-curve-getPointAtDist curve dsttmp) pt T))
(while (< (setq dsttmp (* (setq j (+ j 2)) #dist)) len) (eLine (vlax-curve-getPointAtDist curve dsttmp) 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 #171560 để đọc hướng dẫn và trao đổi thêm.
