;;这个问题,好象本论坛很多的嘛
;;下面是我下载,谁写的不记得了,敬请原谅
- (defun TextToMText
- (/ BLST BOX BOXL E EL H L N OLDH OLDST PY SS SSL ST STRL X)
- (if (setq ss (ssget '((0 . "text"))))
- (progn
- (setq
- ssl (sslength ss)
- n -1
- oldh (getvar "textsize")
- oldst (getvar "textstyle")
- )
- (repeat ssl
- (setq
- e (ssname ss (setq n (1+ n)))
- el (entget e)
- box (textbox (vl-remove (assoc 50 el) el))
- boxl (cons box boxl)
- l (+ (abs (caadr box)) (abs (cadadr box)))
- blst (cons l blst)
- strl (cons
- (list (cdr (assoc 10 el)) (cdr (assoc 1 el)))
- strl
- )
- h (if (and h (> (cdr (assoc 40 el)) h))
- (setq h (cdr (assoc 40 el)))
- (setq h (cdr (assoc 40 el)))
- )
- st (if (not st)
- (cdr (assoc 7 el))
- st
- )
- )
- )
- (setvar "textsize" h)
- (if (/= (getvar "textstyle") st)
- (setvar "textstyle" st)
- )
- (setq
- strl (vl-sort strl
- '(lambda (e1 e2)
- (if (equal (cadar e1) (cadar e2) 0.00001)
- (< (caar e1) (caar e2))
- (> (cadar e1) (cadar e2))
- )
- )
- )
- py (apply 'max (mapcar 'cadr (apply 'append boxl)))
- )
- (vla-addmtext
- (vla-get-modelspace
- (vla-get-activedocument
- (vlax-get-acad-object)
- )
- )
- (vlax-3d-point
- (list (caaar strl) (+ py (cadaar strl)))
- )
- (apply 'max blst)
- (apply 'strcat
- (mapcar
- '(lambda (x)
- (strcat (last x) "\\P")
- )
- strl
- )
- )
- )
- (command ".erase" ss "")
- (setvar "textsize" oldh)
- (setvar "textstyle" oldst)
- )
- )
- )
- ;;1.2 Mtext转text
- (defun MtextToText (/ EN N SS)
- (setq ss (ssget (list (cons 0 "MTEXT"))))
- (if ss
- (repeat (setq n (sslength ss))
- (setq en (ssname ss (setq n (1- n))))
- (command "_.explode" en)
- )
- )
- )
|