Jump to content

Lisp thay đổi chiều cao text của dimstyle cực nhanh !

Lisp này quả thật rất hữu ích, nhưng còn một trường hợp lisp chưa xét đến, em sử dụng mới phát hiện ra. Đó là với các Dimstyle mà được FIX cứng chiều cao của text trong mục text style thì lisp không thay đổi được chiều cao, và em muốn có thêm cái tính năng lưu giá trị chiều cao vừa nhập của lần trước ạ. Anh ketxu này giúp em nhé
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=53208&pid=183218&st=0&#entry183218
(defun c:hdim (/ lstDstyle tH i ss ent dstyle)
(grtext -1 "Free lisp from Cadviet @Ketxu")
(command "undo" "be")
(setvar "cmdecho" 0)
(setq tH (getreal "\n Text Height :") 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 "DIMTXT" (/ tH (getvar "DIMSCALE")))
(command "DIMSTYLE" "S" dstyle "Y")
)
)
)
(setq i (1+ i))
)
(command "undo" "en")
)

Cách dùng

  1. Tải tệp 184022_hdim.lsp về máy.
  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 HDIM để chạy lisp.

Mã nguồn 184022_hdim.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/53208-y%C3%AAu-c%E1%BA%A7u-lisp-thay-%C4%91%E1%BB%95i-chi%E1%BB%81u-cao-text-c%E1%BB%A7a-dimstyle-c%E1%BB%B1c-nhanh/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=53208&pid=183218&st=0entry183218
(defun c:hdim (/ lstDstyle tH i ss ent dstyle)
(grtext -1 "Free lisp from Cadviet @Ketxu")
(command "undo" "be")
(setvar "cmdecho" 0)
(setq tH (getreal "\n Text Height :") 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 "DIMTXT" (/ tH (getvar "DIMSCALE")))
(command "DIMSTYLE" "S" dstyle "Y")
  )  
 )
)
(setq i (1+ i))
)
(command "undo" "en")
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [yêu cầu] Lisp thay đổi chiều cao text của dimstyle cực nhanh !. Xem đúng bài viết #184022 để đọc hướng dẫn và trao đổi thêm.

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