Lisp lệnh FF trong chủ đề “Đóng Ngoặc Text, Mtext, Dim”
Trong trường hợp này mình sữa dòng (if (= enttxt "TEXT")
thành dòng (if (= enttxt "*TEXT, *DIMENSION") sao không chon được mtext và dim vậy các bạn(đầu tiên thì chọn được TEXT rồi)? Các bạn sữa hộ giúp mình lsp này với.
;;;*************************DAU PHI***************************
(defun c:ff ()
(setvar "cmdecho" 0)
(setq olderr *error* *error* myerror)
(prompt "\nHay chon dong TEXT !... ")
(prompt "\nSelect objects: ")
(command "select" "au" pause)
(setq sstxt (ssget "p")
sslen (sslength sstxt)
ctr 0
)
(command ".undo" "mark")
(while (< ctr sslen)
(setq listxt (entget (ssname sstxt ctr))
txttxt (cdr (assoc 1 listxt))
enttxt (cdr (assoc 0 listxt))
)
(if (= enttxt "TEXT")
(progn
(setq testxt (substr txttxt 1 3))
(if (or (= testxt "%%C") (= testxt "%%C"))
(setq newtxt (substr txttxt 4))
(setq newtxt (strcat "%%C" txttxt))
)
(setq listxt (subst (cons 1 newtxt) (assoc 1 listxt) listxt))
(entmod listxt)
)
)
(setq ctr (1+ ctr))
)
(setq *error* olderr)
(setvar "cmdecho" 1)
(princ)
)
- Tải lisp
- 398620_ff.lsp
Cách dùng
- Tải tệp 398620_ff.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 FF để chạy lisp.
Mã nguồn 398620_ff.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/161551-%C4%91%C3%B3ng-ngo%E1%BA%B7c-text-mtext-dim/
;;;*************************DAU PHI***************************
(defun c:ff ()
(setvar "cmdecho" 0)
(setq olderr *error* *error* myerror)
(prompt "\nHay chon dong TEXT !... ")
(prompt "\nSelect objects: ")
(command "select" "au" pause)
(setq sstxt (ssget "p")
sslen (sslength sstxt)
ctr 0
)
(command ".undo" "mark")
(while (< ctr sslen)
(setq listxt (entget (ssname sstxt ctr))
txttxt (cdr (assoc 1 listxt))
enttxt (cdr (assoc 0 listxt))
)
(if (= enttxt "TEXT")
(progn
(setq testxt (substr txttxt 1 3))
(if (or (= testxt "%%C") (= testxt "%%C"))
(setq newtxt (substr txttxt 4))
(setq newtxt (strcat "%%C" txttxt))
)
(setq listxt (subst (cons 1 newtxt) (assoc 1 listxt) listxt))
(entmod listxt)
)
)
(setq ctr (1+ ctr))
)
(setq *error* olderr)
(setvar "cmdecho" 1)
(princ)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề Đóng Ngoặc Text, Mtext, Dim. Xem đúng bài viết #398620 để đọc hướng dẫn và trao đổi thêm.