多行文本转单行单线字体
;;多行文本转单行单线字体(defun c:zt (/ dxflst e i ii len n newstr num obj pt ss str strnum tn tnlst tnlstn txthight)
(setvar "cmdecho" 0)
(setq ss (ssget '((0 . "MTEXT"))))
(setq n 0)
(repeat (sslength ss)
(setq e (ssname ss n))
(setq dxflst (EH-Get-EntDxf e '(10 40))) ;;返回格式 ((363.089 97.6808 0.0) 46.3501)
(setq pt (car dxflst))
(setq txthight (cadr dxflst))
(setq pt (list (car pt)(- (cadr pt) txthight)))
;;
(setq obj (vlax-ename->vla-object e))
(setq Str (vlax-get obj 'TextString))
;;
(setq strnum (vl-string->list Str));字符串转ascii代码表
(setq len (length strnum))
;;
(setq i 0);取表内asccii代码值用
(setq ii 0);变量编号用
(setq tn "tn");变量编号用
(setq tnlstn '()) ;临时变量赋值用列表
;;
(repeat len
(setq num (nth i strnum))
(if (or
(= num 123)
(= num 125)
(= num 92)
(= num 59)
(= num 44)
(and (= num 161)(= (nth (1+ i) strnum) 162))
(and (= num 162) (= (nth (1- i) strnum) 161))
(and (= num 163)(= (nth (1+ i) strnum) 187))
(and (= num 187) (= (nth (1- i) strnum) 163))
(and (= num 163)(= (nth (1+ i) strnum) 172))
(and (= num 172)(= (nth (1- i) strnum) 163))
)
(progn
;(setq tnlst (strcat tn (itoa (setq ii (1+ ii)))))
(setq tnlst nil)
(setq tnlstn '())
)
(progn
(if (null tnlst)(setq tnlst (strcat tn (itoa (setq ii (1+ ii))))))
(set (read tnlst) (setq tnlstn (append tnlstn (list num))))
)
);if
(setq i (1+ i))
) ;repeat文本截断
(setq newstr (vl-list->string (vl-symbol-value (read (strcat tn (itoa ii))))));ascii代码表转字符串
(if newstr
(EH-Make-Text pt txthight nil 0 nil newstr "中Z-04--墙料编号")
)
;变量清空
(setq ii (1+ ii))
(repeat ii
(setq tnlst (strcat tn (itoa (setq ii (1- ii)))))
(set (read tnlst) nil)
)
(vla-Delete obj)
(setq n (+ n 1))
)
(setvar "cmdecho" 1)
(princ)
);defun_end
多行文本炸开就是单行文本 谢谢! Gray-wolf 分享收藏了!!!! 缺少自定义函数
EH-Get-EntDxf
EH-Make-Text
; 错误: no function definition: EH-GET-ENTDXF 兄弟看下 (EH-Make-Textpttxthight nil 0 nil newstr "中Z-04--墙料编号") 这句没弄明白 生成文字的自定义函数中 两个nil是指的啥? 似乎整复杂了,直接炸开不可以吗?直接炸开得到单行问题,再修改字体样式就行了
页:
[1]