: Lisp chèn đối tượng theo lý trình
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=62370&hl=&fromsearch=1
(defun c:lt(/ lst lt pt curve txtsiz msp i)
(grtext -1 "Free from Cadviet @Ketxu")
(command "undo" "be")
(vl-load-com)
(mapcar 'set '(curve pt) (nentselp "\nPick start point:"))
(setq isFirst (< (distance (vlax-curve-getStartPoint curve) pt)(distance (vlax-curve-getEndPoint curve) pt)) i 0
ln (vlax-curve-getDistAtParam curve (vlax-curve-getEndParam curve ))
)
(while (and (setq lt (getreal (strcat "\nNhap ly trinh diem thu " (itoa (setq i (1+ i))) " : "))) (< lt ln))
(entmake
(list (cons 0 "CIRCLE")
(cons 10 (vlax-curve-getPointAtDist curve (if isFirst lt (- ln lt))))
(cons 40 0.1) ;Kich thuoc vong tron
)
)
(setq lst (cons (cons i lt) lst))
)
(setq pt (getpoint "\nDiem dat bang thong ke:")
txtsiz (* (getvar "dimtxt")(getvar "dimscale"))
msp (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(foreach e (reverse lst)
(vla-addtext msp (itoa (car e)) (vlax-3d-point pt) txtsiz)
(vla-addtext msp (rtos (cdr e) 2 2) (vlax-3d-point (polar pt 0 (* 5 txtsiz))) txtsiz )
(setq pt (polar pt (/ pi -2) (* 1.5 txtsiz)))
)
(command "undo" "en")
)
- Tải lisp
- 192066_lt.lsp
Cách dùng
- Tải tệp 192066_lt.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 LT để chạy lisp.
Mã nguồn 192066_lt.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/62370-y%C3%AAu-c%E1%BA%A7u-lisp-ch%C3%A8n-%C4%91%E1%BB%91i-t%C6%B0%E1%BB%A3ng-theo-l%C3%BD-tr%C3%ACnh/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=62370&hl=&fromsearch=1
(defun c:lt(/ lst lt pt curve txtsiz msp i)
(grtext -1 "Free from Cadviet @Ketxu")
(command "undo" "be")
(vl-load-com)
(mapcar 'set '(curve pt) (nentselp "\nPick start point:"))
(setq isFirst (< (distance (vlax-curve-getStartPoint curve) pt)(distance (vlax-curve-getEndPoint curve) pt)) i 0
ln (vlax-curve-getDistAtParam curve (vlax-curve-getEndParam curve ))
)
(while (and (setq lt (getreal (strcat "\nNhap ly trinh diem thu " (itoa (setq i (1+ i))) " : "))) (< lt ln))
(entmake
(list (cons 0 "CIRCLE")
(cons 10 (vlax-curve-getPointAtDist curve (if isFirst lt (- ln lt))))
(cons 40 0.1) ;Kich thuoc vong tron
)
)
(setq lst (cons (cons i lt) lst))
)
(setq pt (getpoint "\nDiem dat bang thong ke:")
txtsiz (* (getvar "dimtxt")(getvar "dimscale"))
msp (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(foreach e (reverse lst)
(vla-addtext msp (itoa (car e)) (vlax-3d-point pt) txtsiz)
(vla-addtext msp (rtos (cdr e) 2 2) (vlax-3d-point (polar pt 0 (* 5 txtsiz))) txtsiz )
(setq pt (polar pt (/ pi -2) (* 1.5 txtsiz)))
)
(command "undo" "en")
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [ YÊU CẦU] : Lisp chèn đối tượng theo lý trình. Xem đúng bài viết #192066 để đọc hướng dẫn và trao đổi thêm.