Lisp lệnh WO trong chủ đề “[yêu cầu] Thay đổi chiều cao các text trong Block Attbute”
Em có tham khảo và sử dụng các "Lisp chỉnh style TEXT trong block thuộc tính" trên diễn đàn như: wo.lsp, rba_wo_ho.lsp, ho_Styb.lsp... tuy nhiên các Lisp trên chỉ thay đổi chiều rộng, chiều cao, Style của các Attribute
chứ không thay đổi được cho các "Text" của Block Attribute.
Em có nhiều Block Attribute ghi diện tích như trong hìnhhttps://www.cadviet.com/upfiles/3/88193_thay_doi_chieu_cao_text.png...
Nhờ các Bác viết giúp em lisp chỉnh chiều cao cho cả Text và Attribute cho Block với.
Xin chân thành cảm ơn !
;; free lisp from cadviet.com-- Doi chieu cao, do rong, style cho Attribute cua Blocks
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=47445&st=0
(defun c:wo( / ssdt sodt index tt entdt w getsty h)
(setq ssdt (ssget '((0 . "INSERT") (66 . 1)))
sodt (sslength ssdt)
index 0
)
(setq w (getreal "\n Nhap be rong chu :"))
(setq h (getreal "\n Nhap chieu cao chu :"))
(if (> (atof (substr (getvar "ACADVER") 1 4)) 16.1)
(progn
(or newsty (setq newsty (getvar "textstyle")))
(setq res "" resinit "" tbsty nil)
(while (setq tbsty (tblnext "style" (null tbsty)))
(setq sty (cdr (assoc 2 tbsty))
res (strcat res "/" sty )
resinit (strcat resinit " " sty )))
(setq res (substr res 2)
resinit (substr resinit 2))
(setq cur_var (mapcar 'getvar '("DYNMODE" "DYNPROMPT")))
(mapcar 'setvar '("DYNMODE" "DYNPROMPT") '(1 1))
(initget (strcat " " resinit))
(setq getsty (getkword (strcat "\nChon Style ") ))
(and getsty (setq newsty getsty))
(mapcar 'setvar '("DYNMODE" "DYNPROMPT") cur_var)
)
(setq getsty (getstring (strcat "\nChon Style ") ))
)
(repeat sodt
(setq entdt (ssname ssdt index)
index (1+ index))
(while (/= (cdr(assoc 0 (entget entdt))) "SEQEND")
(setq
entdt (entnext entdt)
tt (entget entdt)
)
(if getsty (if (tblsearch "style" getsty) (setq tt (subst (cons 7 getsty) (assoc 7 tt) tt))) )
(if w (setq tt (subst (cons 41 w) (assoc 41 tt) tt)))
(if h (setq tt (subst (cons 40 h) (assoc 40 tt) tt)))
(entmod tt)
(entupd entdt)
)
)
(princ)
)
chứ không thay đổi được cho các "Text" của Block Attribute.
Em có nhiều Block Attribute ghi diện tích như trong hìnhhttps://www.cadviet.com/upfiles/3/88193_thay_doi_chieu_cao_text.png...
Nhờ các Bác viết giúp em lisp chỉnh chiều cao cho cả Text và Attribute cho Block với.
Xin chân thành cảm ơn !
;; free lisp from cadviet.com-- Doi chieu cao, do rong, style cho Attribute cua Blocks
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=47445&st=0
(defun c:wo( / ssdt sodt index tt entdt w getsty h)
(setq ssdt (ssget '((0 . "INSERT") (66 . 1)))
sodt (sslength ssdt)
index 0
)
(setq w (getreal "\n Nhap be rong chu :"))
(setq h (getreal "\n Nhap chieu cao chu :"))
(if (> (atof (substr (getvar "ACADVER") 1 4)) 16.1)
(progn
(or newsty (setq newsty (getvar "textstyle")))
(setq res "" resinit "" tbsty nil)
(while (setq tbsty (tblnext "style" (null tbsty)))
(setq sty (cdr (assoc 2 tbsty))
res (strcat res "/" sty )
resinit (strcat resinit " " sty )))
(setq res (substr res 2)
resinit (substr resinit 2))
(setq cur_var (mapcar 'getvar '("DYNMODE" "DYNPROMPT")))
(mapcar 'setvar '("DYNMODE" "DYNPROMPT") '(1 1))
(initget (strcat " " resinit))
(setq getsty (getkword (strcat "\nChon Style ") ))
(and getsty (setq newsty getsty))
(mapcar 'setvar '("DYNMODE" "DYNPROMPT") cur_var)
)
(setq getsty (getstring (strcat "\nChon Style ") ))
)
(repeat sodt
(setq entdt (ssname ssdt index)
index (1+ index))
(while (/= (cdr(assoc 0 (entget entdt))) "SEQEND")
(setq
entdt (entnext entdt)
tt (entget entdt)
)
(if getsty (if (tblsearch "style" getsty) (setq tt (subst (cons 7 getsty) (assoc 7 tt) tt))) )
(if w (setq tt (subst (cons 41 w) (assoc 41 tt) tt)))
(if h (setq tt (subst (cons 40 h) (assoc 40 tt) tt)))
(entmod tt)
(entupd entdt)
)
)
(princ)
)
- Tải lisp
- 211539_wo.lsp
Cách dùng
- Tải tệp 211539_wo.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 WO để chạy lisp.
Mã nguồn 211539_wo.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/66259-y%C3%AAu-c%E1%BA%A7u-thay-%C4%91%E1%BB%95i-chi%E1%BB%81u-cao-c%C3%A1c-text-trong-block-attbute/
;; free lisp from cadviet.com-- Doi chieu cao, do rong, style cho Attribute cua Blocks
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=47445&st=0
(defun c:wo( / ssdt sodt index tt entdt w getsty h)
(setq ssdt (ssget '((0 . "INSERT") (66 . 1)))
sodt (sslength ssdt)
index 0
)
(setq w (getreal "\n Nhap be rong chu :"))
(setq h (getreal "\n Nhap chieu cao chu :"))
(if (> (atof (substr (getvar "ACADVER") 1 4)) 16.1)
(progn
(or newsty (setq newsty (getvar "textstyle")))
(setq res "" resinit "" tbsty nil)
(while (setq tbsty (tblnext "style" (null tbsty)))
(setq sty (cdr (assoc 2 tbsty))
res (strcat res "/" sty )
resinit (strcat resinit " " sty )))
(setq res (substr res 2)
resinit (substr resinit 2))
(setq cur_var (mapcar 'getvar '("DYNMODE" "DYNPROMPT")))
(mapcar 'setvar '("DYNMODE" "DYNPROMPT") '(1 1))
(initget (strcat " " resinit))
(setq getsty (getkword (strcat "\nChon Style [" res " ] ") ))
(and getsty (setq newsty getsty))
(mapcar 'setvar '("DYNMODE" "DYNPROMPT") cur_var)
)
(setq getsty (getstring (strcat "\nChon Style [" res " ] ") ))
)
(repeat sodt
(setq entdt (ssname ssdt index)
index (1+ index))
(while (/= (cdr(assoc 0 (entget entdt))) "SEQEND")
(setq
entdt (entnext entdt)
tt (entget entdt)
)
(if getsty (if (tblsearch "style" getsty) (setq tt (subst (cons 7 getsty) (assoc 7 tt) tt))) )
(if w (setq tt (subst (cons 41 w) (assoc 41 tt) tt)))
(if h (setq tt (subst (cons 40 h) (assoc 40 tt) tt)))
(entmod tt)
(entupd entdt)
)
)
(princ)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [yêu cầu] Thay đổi chiều cao các text trong Block Attbute. Xem đúng bài viết #211539 để đọc hướng dẫn và trao đổi thêm.