Lisp lệnh TGLL trong chủ đề “[Nhờ chỉnh sửa] Lisp tính tổng pline ed vào đuôi text”
Là "tân binh" nên tạm sửa cho bạn thế này :D :D :D
Có gì thì từ từ sửa tiếp
p/s: Chữ "L" trong text của bạn phải luôn là chữ in hoa đó, tạm thế đã
;; free lisp from cadviet.com ;;;-------------------------------------------------------------------- (defun Length1(e) (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) ;;;-------------------------------------------------------------------- (defun C:TGLL( / ss L e) (setq ss (ssget (list (cons 0 "LINE,ARC,CIRCLE,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE"))) L 0.0 ) (vl-load-com) (while (setq e (ssname ss 0)) (setq L (+ L (length1 e))) (ssdel e ss) ) (setq te (entget(car(entsel"\n Chon Text de gan ket qua :"))) te (subst (cons 1 (strcat (CAT (cdr (assoc 1 te)) "L") (rtos L 2 0))) (assoc 1 te) te)) (entmod te) ) ;;;-------------------------------------------------------------------- ;Ham lay ki tu thu n cua chuoi: (defun TIM(str n) (substr str n 1) ) ;------------------- ;Ham cat chuoi co 1 ky tu "x" tu dau den ky tu "x" (defun CAT(str x / i) (setq i 0) (while (/= (TIM str (setq i (1+ i))) x) (substr str 1 (1+ i)) ) )
Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.
Cách dùng
- Chép mã nguồn, lưu thành tệp 281108_tgll.lsp.
- 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 TGLL để chạy lisp.
Mã nguồn 281108_tgll.lsp (trích từ bài viết gốc)
;; free lisp from cadviet.com
;;;--------------------------------------------------------------------
(defun Length1(e) (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)))
;;;--------------------------------------------------------------------
(defun C:TGLL( / ss L e)
(setq
ss (ssget (list (cons 0 "LINE,ARC,CIRCLE,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE")))
L 0.0
)
(vl-load-com)
(while (setq e (ssname ss 0))
(setq L (+ L (length1 e)))
(ssdel e ss)
)
(setq te (entget(car(entsel"\n Chon Text de gan ket qua :")))
te (subst (cons 1 (strcat (CAT (cdr (assoc 1 te)) "L") (rtos L 2 0))) (assoc 1 te) te))
(entmod te)
)
;;;--------------------------------------------------------------------
;Ham lay ki tu thu n cua chuoi:
(defun TIM(str n)
(substr str n 1)
)
;-------------------
;Ham cat chuoi co 1 ky tu "x" tu dau den ky tu "x"
(defun CAT(str x / i)
(setq i 0)
(while (/= (TIM str (setq i (1+ i))) x)
(substr str 1 (1+ i))
)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Nhờ chỉnh sửa] Lisp tính tổng pline ed vào đuôi text. Xem đúng bài viết #281108 để đọc hướng dẫn và trao đổi thêm.