Lisp lệnh DSTT trong chủ đề “Đánh số thứ tự tăng dần”
Tue_NV mới viết cái Lisp này.Hy vọng bạn hài lòng :
(defun c:dstt(/ dau tong po po1 ent i) (prompt "\n Danh so thu tu dang n/m ") (setvar "cmdecho" 0) (setq dau (getint "\n Danh so bat dau (n) :")) (setq tong (getint "\n Danh so tong (m) :")) (setq po (getpoint (strcat "\n Cho diem chen cua so : " (itoa dau) "/" (itoa tong))) i 1) (wtxt (strcat (itoa dau) "/" (itoa tong)) po) (Repeat (- tong dau) (setq po1 (getpoint po (strcat "\n Cho diem chen cua so : " (itoa (+ dau i)) "/" (itoa tong)))) (command "copy" "L" "" po po1) (setq ent (entget(entlast))) (setq ent (subst (cons 1 (strcat(itoa (+ dau i)) "/" (itoa tong))) (assoc 1 ent) ent)) (entmod ent) (setq i (1+ i)) (setq po po1) ) (princ) ) ; (defun wtxt (txt p / sty d h) (setq sty (getvar "textstyle") d (tblsearch "style" sty) h (cdr (assoc 40 d))) (entmake (list (cons 0 "TEXT") (cons 7 sty) (cons 1 txt) (cons 10 p) (cons 11 p) (cons 72 1) (cons 73 2) (if (> h 0) (cons 40 h) (assoc 40 d)) (assoc 41 d)) ) )
Hay quá , cảm ơn bác Tue_NV nhé .
- Tải lisp
- 65257_dstt.lsp
Cách dùng
- Tải tệp 65257_dstt.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 DSTT để chạy lisp.
Mã nguồn 65257_dstt.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/1398-%C4%91%C3%A1nh-s%E1%BB%91-th%E1%BB%A9-t%E1%BB%B1-t%C4%83ng-d%E1%BA%A7n/?page=2
(defun c:dstt(/ dau tong po po1 ent i)
(prompt "\n Danh so thu tu dang n/m ")
(setvar "cmdecho" 0)
(setq dau (getint "\n Danh so bat dau (n) :"))
(setq tong (getint "\n Danh so tong (m) :"))
(setq po (getpoint (strcat "\n Cho diem chen cua so : " (itoa dau) "/" (itoa tong))) i 1)
(wtxt (strcat (itoa dau) "/" (itoa tong)) po)
(Repeat (- tong dau)
(setq po1 (getpoint po (strcat "\n Cho diem chen cua so : " (itoa (+ dau i)) "/" (itoa tong))))
(command "copy" "L" "" po po1)
(setq ent (entget(entlast)))
(setq ent (subst (cons 1 (strcat(itoa (+ dau i)) "/" (itoa tong))) (assoc 1 ent) ent))
(entmod ent)
(setq i (1+ i))
(setq po po1)
)
(princ)
)
;
(defun wtxt (txt p / sty d h)
(setq sty (getvar "textstyle")
d (tblsearch "style" sty)
h (cdr (assoc 40 d)))
(entmake (list (cons 0 "TEXT") (cons 7 sty) (cons 1 txt) (cons 10 p) (cons 11 p)
(cons 72 1) (cons 73 2)
(if (> h 0) (cons 40 h) (assoc 40 d)) (assoc 41 d))
)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Đánh số thứ tự tăng dần. Xem đúng bài viết #65257 để đọc hướng dẫn và trao đổi thêm.