Jump to content

Lisp lệnh FDIMA FDIMB FDIMC trong chủ đề “"yêu cầu" Lisp thay đổi font dim hàng loạt”

Dựa theo lisp của Ketxu trong bài này: https://www.cadviet.com/forum/topic/53208-yeu-cau-lisp-thay-doi-chieu-cao-text-cua-dimstyle-cuc-nhanh/
Xin phép  Ketxu sửa lại giúp chủ thớt:

;;; 1. Change cho toan bo DimStyle trong ban ve :
(defun c:fdima (/ table ts)
(grtext -1 "Free lisp from Cadviet @Ketxu")
(command "undo" "be")
(defun table (s / d r)
(while (setq d (tblnext s (null d)))
(setq r (cons (cdr (assoc 2 d)) r))))
(setq ts (getstring "\nText Style: "))
(setvar "cmdecho" 0)
(mapcar '(lambda(x)(command "-DIMSTYLE" "R" x)(setvar "DIMTXSTY" ts)(command "-DIMSTYLE" "S" x "Y")) (table "DIMSTYLE"))
(command "undo" "en")(princ))

;;; 2. Pick den dau change den do:
(defun c:fdimb (/ lstDstyle ts ent dstyle)
(grtext -1 "Free lisp from Cadviet @Ketxu")
(command "undo" "be")
(setvar "cmdecho" 0)
(setq ts (getstring "\nText Style: "))
(while (setq ent (car (entsel "\n Pick dim :")))
(if (setq dstyle (cdr (assoc 3 (entget ent))))
(if (not (vl-position dstyle lstDstyle))
(progn
(setq lstDstyle (cons dstyle lstDstyle))
(command "-DIMSTYLE" "R" dstyle)(setvar "DIMTXSTY" ts)(command "-DIMSTYLE" "S" dstyle "Y")
)
(princ "\nAlready Dimension Style Picked")
)
)
)
(command "undo" "en")
(princ))
;;;; 3. Chon 1 loat roi change:
(defun c:fdimc (/ lstDstyle ts i ss ent dstyle)
(grtext -1 "Free lisp from Cadviet @Ketxu")
(command "undo" "be")
(setvar "cmdecho" 0)
(setq ts (getstring "\nText Style: ") i 0 ss (ssget (list (cons 0 "DIMENSION"))))
(while (setq ent (ssname ss i))
(if (setq dstyle (cdr (assoc 3 (entget ent))))
(if (not (vl-position dstyle lstDstyle))
(progn
(setq lstDstyle (cons dstyle lstDstyle))
(command "-DIMSTYLE" "R" dstyle)(setvar "DIMTXSTY" ts)(command "-DIMSTYLE" "S" dstyle "Y")
)
)
)
(setq i (1+ i))
)
(command "undo" "en")
(princ))

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

  1. Chép mã nguồn, lưu thành tệp 320750_fdima_fdimb_fdimc.lsp.
  2. 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ẽ.
  3. Gõ lệnh FDIMA FDIMB FDIMC để chạy lisp.

Thảo luận gốc

Lisp được chia sẻ trong chủ đề "yêu cầu" Lisp thay đổi font dim hàng loạt. Xem đúng bài viết #320750 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 181)