Jump to content

Lisp lệnh DF trong chủ đề “Lisp đổi Font cho text được chọn tại sao lỗi với Font .vnarial narrow !!!!!!”

Đây là đoạn Code đổi font của Text sang font .vnarial narrow

(defun c:df ()
(command "undo" "be")
(command "-style" "doifont" "VNARIALN.TTF" "0" "1" "0" "n" "n")
(prompt "\nChon chu muon chinh.")
(setq ss (ssget))
(setq c 0)
(if ss (setq e (ssname ss c)))
(while e
(setq e (entget e))
(if (= (cdr (assoc 0 e)) "TEXT")
(progn
(setq txt "doifont")
(setq e (subst (cons 7 txt) (assoc 7 e) e))
(entmod e)
)
)
(setq c (1+ c))
(setq e (ssname ss c))
)
(command "undo" "end")
(Princ)
)

Còn đây là đoạn Code đổi font của Text sang font .vnarial narrowH

(defun c:df ()
(command "undo" "be")
(command "-style" "doifont" "VHARIALN.TTF" "0" "1" "0" "n" "n")
(prompt "\nChon chu muon chinh.")
(setq ss (ssget))
(setq c 0)
(if ss (setq e (ssname ss c)))
(while e
(setq e (entget e))
(if (= (cdr (assoc 0 e)) "TEXT")
(progn
(setq txt "doifont")
(setq e (subst (cons 7 txt) (assoc 7 e) e))
(entmod e)
)
)
(setq c (1+ c))
(setq e (ssname ss c))
)
(command "undo" "end")
(Princ)
)

Chúc thành công ^_^

Chạy tốt rồi, cảm ơn bác Tuệ nhiều nhé !

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 48579_df.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 DF để chạy lisp.

Mã nguồn 48579_df.lsp (trích từ bài viết gốc)

(defun c:df ()
(command "undo" "be")
(command "-style" "doifont" "VNARIALN.TTF" "0" "1" "0" "n" "n")
(prompt "\nChon chu muon chinh.")
(setq ss (ssget))
(setq c 0)
(if ss (setq e (ssname ss c)))
(while e
(setq e (entget e))
(if (= (cdr (assoc 0 e)) "TEXT")
(progn
(setq txt "doifont")
(setq e (subst (cons 7 txt) (assoc 7 e) e))
(entmod e)
)
)
(setq c (1+ c))
(setq e (ssname ss c))
)
(command "undo" "end")
(Princ)
)

(defun c:df ()
(command "undo" "be")
(command "-style" "doifont" "VHARIALN.TTF" "0" "1" "0" "n" "n")
(prompt "\nChon chu muon chinh.")
(setq ss (ssget))
(setq c 0)
(if ss (setq e (ssname ss c)))
(while e
(setq e (entget e))
(if (= (cdr (assoc 0 e)) "TEXT")
(progn
(setq txt "doifont")
(setq e (subst (cons 7 txt) (assoc 7 e) e))
(entmod e)
)
)
(setq c (1+ c))
(setq e (ssname ss c))
)
(command "undo" "end")
(Princ)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Lisp đổi Font cho text được chọn tại sao lỗi với Font .vnarial narrow !!!!!!. Xem đúng bài viết #48579 để đọc hướng dẫn và trao đổi thêm.

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