Lisp lệnh MAT trong chủ đề “Lisp MATTEXT bị lỗi ???”
Update theo yêu cầu: số số lẻ do nguời dùng nhập.
- Tải lisp
- 77689_mat.lsp
Cách dùng
- Tải tệp 77689_mat.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 MAT để chạy lisp.
Mã nguồn 77689_mat.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/14405-lisp-mattext-b%E1%BB%8B-l%E1%BB%97i/?tab=comments#comment-77689
(defun C:mat(/ ent typ nd ss ssle)
(command "_.undo" "_begin")
(or vlax-ename->vla-object (vl-load-com))
(while
(not
(and (setq ent (car (nentsel "\nChon doi tuong de lay Text hay Chieu dai :")))
(setq ent (vlax-ename->vla-object ent))
(setq typ (vla-get-ObjectName ent))
(cond
((wcmatch typ "*Text,*MLeader,*Attribute")
(setq nd (vla-get-TextString ent)) )
((wcmatch typ "*AttributeDefinition")
(setq nd (vla-get-TagString ent)) )
((wcmatch typ "*Line,*Spline,*Polyline,*Arc,*Circle,*Ellipse")
(or *ssle* (setq *ssle* 0))
(initget 4)
(setq ssle (getint (strcat "\nSo so le <" (itoa *ssle*) ">: ")))
(if ssle (setq *ssle* ssle))
(setq nd (rtos (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)) 2 *ssle*)) )
(t nil)
); cond
))
(princ "\nDoi tuong chon khong hop le, Chon lai : "))
(princ (strcat"\nChon doi tuong de thay the gia tri Text <" nd "> :" ))
(if (setq ss (ssget (list (cons 0 "*TEXT,*DIMENSION,MULTILEADER,ATTDEF")) ))
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq ent (vlax-ename->vla-object ent)
typ (vla-get-ObjectName ent))
(cond
((wcmatch typ "*Text,*MLeader") (vla-put-TextString ent nd) )
((wcmatch typ "*Dimension*") (vla-put-TextOverride ent nd) )
((wcmatch typ "*AttributeDefinition") (vla-put-TagString ent nd) )
); cond
)
)
(command "_.undo" "_end")
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Lisp MATTEXT bị lỗi ???. Xem đúng bài viết #77689 để đọc hướng dẫn và trao đổi thêm.