我一直在使用一段代码来修改dtext对象的文本字符串,然后将其转换为多行文字。
(defun c:efg ( / a e o s x d oldd new-dxf) (if (setq s (ssget "_:L" '((0 . "TEXT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) x (entget e) a (assoc 1 x) oldd (assoc 41 x) ) (entmod (subst (cons 1 (strcat "{\\H0.15;"(substr (cdr a) 1 4)"}" "{\\H0.15;(0.--" "x0.--" ")}")) a x)) (command "_.txt2mtxt" e "") ) ) (princ))
然而,我注意到,在将其转换为多行文字后,对象的标识符发生了变化,我相信由于这个原因,我不能再次使用entmod。所以我想在转换成多行文字后再做一次身份识别,就像这样
(defun c:efg ( / a e o s x d oldd new-dxf b n m) (if (setq s (ssget "_:L" '((0 . "TEXT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) ;first identity grab x (entget e) a (assoc 1 x) ) ;;;; do stuff on all the identities (entmod (subst (cons 1 (strcat "{\\H0.15;"(substr (cdr a) 1 4)"}" "{\\H0.15;(0.--" "x0.--" ")}")) a x)) (command "_.txt2mtxt" e "") (setq b (ssname n (setq i (1- i))) ;second identity grab m (entget b) oldd (assoc 41 m) new-dxf '(41 . 1.5) d (subst new-dxf oldd m) ) ;;;; modify the width of the mtext (entmod d) ) ) (princ))
(41.是多行文字宽度的代码组)
第二次抓取似乎不起作用,有什么提示吗?
编辑:对代码进行了一些更正,现在我得到了一个错误的参数:lselsept
我还注意到,有一个if条件可能无法使用,因为我正在排队mtext,所以我创建了一个单独的if循环
(defun c:efg ( / a e o s x d oldd new-dxf b n m) (if (setq s (ssget "_:L" '((0 . "TEXT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) ;first identity grab x (entget e) a (assoc 1 x) ) ;;;; do stuff on all the identities (entmod (subst (cons 1 (strcat "{\\H0.15;"(substr (cdr a) 1 4)"}" "{\\H0.15;(0.--" "x0.--" ")}")) a x)) (command "_.txt2mtxt" e "") ) ) (if (setq n (ssget "_:L" '((0 . "MTEXT")))) (repeat (setq i (sslength s)) (setq b (ssname n (setq i (1- i))) ;second identity grab m (entget b) oldd (assoc 41 m) new-dxf '(41 . 1.5) d (subst new-dxf oldd m) ) ;;;; modify the width of the mtext (entmod d) ) ) (princ))
仍然得到参数错误