对文字的修改,是cad操作中十分常见的工作之一。给文字添加前缀或者后缀,又是其中常见的任务。
倘若能够批量地添加文字前缀或者后缀,就能极大地提高效率。
本文带来的就是批量添加文字前缀与后缀的cad插件。
批量添加文字前缀的cad插件,总共14行autolisp代码。其中,有效行数11行,核心函数有效代码10行。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
(defun xg/prefix-text (/ d i ls n pre) ; no.5
;; 文字前缀的核心函数
;; 作者:徐工, 微博:@徐工徐工2020,头条:@徐工徐工
(setq pre (getstring "\n输入文字前缀:"))
(if
(and pre (setq ls (ssget '((0 . "text")))) (< 0 (setq n (sslength ls))))
(progn
(setq i 0)
(repeat n
(setq d (entget (ssname ls i))
i (1+ i))
(entmod (subst (cons 1 (strcat pre (cdr (assoc 1 d)))) (assoc 1 d) d))))))
(defun c:qzqz () (xg/prefix-text) (princ))
|
批量添加文字后缀的cad插件,总共14行autolisp代码。其中,有效行数11行,核心函数有效代码10行。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
(defun xg/postfix-text (/ d i ls n post) ; no.6
;; 文字后缀的核心函数
;; 作者:徐工, 微博:@徐工徐工2020,头条:@徐工徐工
(setq post (getstring "\n输入文字后缀:"))
(if
(and post (setq ls (ssget '((0 . "text")))) (< 0 (setq n (sslength ls))))
(progn
(setq i 0)
(repeat n
(setq d (entget (ssname ls i))
i (1+ i))
(entmod (subst (cons 1 (strcat (cdr (assoc 1 d)) post)) (assoc 1 d) d))))))
(defun c:hzhz () (xg/postfix-text) (princ))
|
最后一行的c:hzhz意味着调用命令是hzhz,你可以修改为自己喜欢的快捷键。
文章作者
Jack Hsu
上次更新
2022-03-13
许可协议
Copyright © Jack Hsu. All Rights Reserved.