Xin lisp chuyển text thuộc tính att thành text thường
Xin Khẩn!!
Xin lisp chuyển Text Att đã bị explode (chứ không phải dùng lệnh Burst) Thành Text thường
Giải thích thêm Text ATT đã đc tạo block, Có 2 trường hợp explode:
1- Text Att bị Explode bằng lệnh EX thì text này không còn là text thường nữa. VD: ta dùng lisp đánh số thứ tự cho text att này thì số không tăng dần đc
2- Text Att bị Explode bằng lệnh Burst thì text thường. VD: ta dùng lisp đánh số thứ tự cho text att này thì số tăng dần đc
Xin cảm ơn các anh chị diễn đàn cho xin lisp sớm.
Hỏi ảnh GO trước đi. Heizz. Code này ngon nhé.^_^
(defun c:AttDef2Text ( / ss )
;; © Lee Mac ~ 01.06.10
(vl-load-com)
(if (setq ss (ssget "_:L" '((0 . "ATTDEF"))))
(
(lambda ( i / e o )
(while (setq e (ssname ss (setq i (1+ i))))
(if
(
(if (and (vlax-property-available-p
(setq o (vlax-ename->vla-object e)) 'MTextAttribute)
(eq :vlax-true (vla-get-MTextAttribute o)))
MAttDef2MText AttDef2Text
)
(entget e)
)
(entdel e)
)
)
)
-1
)
)
(princ)
)
(defun AttDef2Text ( eLst / dx74 dx2 )
;; © Lee Mac ~ 01.06.10
(setq dx74 (cdr (assoc 74 eLst)) dx2 (cdr (assoc 2 eLst)))
(entmake
(append '( (0 . "TEXT") ) (RemovePairs '(0 100 1 2 3 73 74 70 280) eLst)
(list
(cons 73 dx74)
(cons 1 dx2)
)
)
)
)
(defun MAttDef2MText ( eLst )
;; © Lee Mac ~ 01.06.10
(entmake
(append '( (0 . "MTEXT") (100 . "AcDbEntity") (100 . "AcDbMText") )
(RemoveFirstPairs '(40 50 41 7 71 72 71 72 73 10 11 11 210)
(RemovePairs '(-1 102 330 360 5 0 100 101 1 2 3 42 43 51 74 70 280) eLst)
)
(list (cons 1 (cdr (assoc 2 eLst))))
)
)
)
(defun RemoveFirstPairs ( pairs lst )
;; © Lee Mac
(defun foo ( pair lst )
(if lst
(if (eq pair (caar lst))
(cdr lst)
(cons (car lst) (foo pair (cdr lst)))
)
)
)
(foreach pair pairs
(setq lst (foo pair lst))
)
lst
)
(defun RemovePairs ( pairs lst )
;; © Lee Mac
(vl-remove-if
(function
(lambda ( pair )
(vl-position (car pair) pairs)
)
)
lst
)
)
- Tải lisp
- 409981_attdef2text.lsp
Cách dùng
- Tải tệp 409981_attdef2text.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 ATTDEF2TEXT để chạy lisp.
Mã nguồn 409981_attdef2text.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/71041-y%C3%AAu-c%E1%BA%A7u-xin-lisp-chuy%E1%BB%83n-text-thu%E1%BB%99c-t%C3%ADnh-att-th%C3%A0nh-text-th%C6%B0%E1%BB%9Dng/
(defun c:AttDef2Text ( / ss )
;; © Lee Mac ~ 01.06.10
(vl-load-com)
(if (setq ss (ssget "_:L" '((0 . "ATTDEF"))))
(
(lambda ( i / e o )
(while (setq e (ssname ss (setq i (1+ i))))
(if
(
(if (and (vlax-property-available-p
(setq o (vlax-ename->vla-object e)) 'MTextAttribute)
(eq :vlax-true (vla-get-MTextAttribute o)))
MAttDef2MText AttDef2Text
)
(entget e)
)
(entdel e)
)
)
)
-1
)
)
(princ)
)
(defun AttDef2Text ( eLst / dx74 dx2 )
;; © Lee Mac ~ 01.06.10
(setq dx74 (cdr (assoc 74 eLst)) dx2 (cdr (assoc 2 eLst)))
(entmake
(append '( (0 . "TEXT") ) (RemovePairs '(0 100 1 2 3 73 74 70 280) eLst)
(list
(cons 73 dx74)
(cons 1 dx2)
)
)
)
)
(defun MAttDef2MText ( eLst )
;; © Lee Mac ~ 01.06.10
(entmake
(append '( (0 . "MTEXT") (100 . "AcDbEntity") (100 . "AcDbMText") )
(RemoveFirstPairs '(40 50 41 7 71 72 71 72 73 10 11 11 210)
(RemovePairs '(-1 102 330 360 5 0 100 101 1 2 3 42 43 51 74 70 280) eLst)
)
(list (cons 1 (cdr (assoc 2 eLst))))
)
)
)
(defun RemoveFirstPairs ( pairs lst )
;; © Lee Mac
(defun foo ( pair lst )
(if lst
(if (eq pair (caar lst))
(cdr lst)
(cons (car lst) (foo pair (cdr lst)))
)
)
)
(foreach pair pairs
(setq lst (foo pair lst))
)
lst
)
(defun RemovePairs ( pairs lst )
;; © Lee Mac
(vl-remove-if
(function
(lambda ( pair )
(vl-position (car pair) pairs)
)
)
lst
)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu cầu] Xin lisp chuyển text thuộc tính att thành text thường. Xem đúng bài viết #409981 để đọc hướng dẫn và trao đổi thêm.