把文字以空格自动换行
本帖最后由 小鸟 于 2023-5-10 01:04 编辑(defun c:tt(/ ss ents txt 2txt )
(setqss (ssget '((0 . "*text"))); 选择文字
ents (entget (ssname ss 0)); dxf码
txt(cdr (assoc 1 ents)); 提取文字
pt (cdr (assoc 10 ents))
a01(parse12 txt " ")
) ;分割字符串
;;; (setq 2txt "")
(foreach n a01
(if(= 2txt nil)
(progn
(setq 2txt n)
)
(progn
(setq 2txt (strcat 2txt "\n" n))
)
)
)
(YD-01文字 2txt pt 10)
(command "_.erase" ss "")
)
(defun YD-01文字 (文字 pta gd / )
(entmake
(list '(0 . "MTEXT")
'(100 . "AcDbEntity")
'(100 . "AcDbMText")
'(7 . "Standard");; 文字样式
(cons 1 文字);;文字内容
(cons 10 pta);;文字插入点
(cons 8 "0");;文字图层
(cons 40 gd);;文字倾斜度
(cons 71 1) ;;水平对正 居中对正
; (cons 73 2) ;;垂直对正 居中对正
)
)
;(princ "异度空间 写文字")
(princ)
)
;;85.12 [功能] 字符串分割 By st788796
;;基本同上parse4 parse8
;;(parse12 "aa ,10 b.10x20,.2" ",."),("aa ,10 b.10x20" "2")
;;(parse12 "aa ,10 b.10x20,.2" "")死循环
(defun parse12 (str delimiter / POST STRL STRLST)
(setq strl (strlen delimiter))
(while (vl-string-search delimiter str)
(setq post (vl-string-search delimiter str))
(setq strlst (append strlst (list (substr str 1 post))))
(setq str (substr str (+ post (1+ strl))))
)
(vl-remove "" (append strlst (list str)))
)
谢谢大佬分享
页:
[1]