参考一下,根据你自己的需要进行修改,如需要,最后还可将其炸开- (defun MakeText(pt1 str h lay style / ptInsert TextDxf)
- (setq TextDxf '(
- (0 . "MTEXT")
- (100 . "AcDbEntity")
- (100 . "AcDbMText")
- )
- )
- (setq TextDxf (append TextDxf (list
- (cons 10 pt1)
- (cons 1 str)
- (cons 40 h)
- (cons 7 style)
- (cons 8 lay)
- )
- )
- )
- (entmake TextDxf)
- (princ)
- )
- (defun text->Mtext(ent_Texts h / h1 i ent_Text ents pt str lay style)
- (setq i 1)
- (setq ent_Texts (vl-sort ent_Texts
- '(lambda (e1 e2) (> (cadr (cdr (assoc 10 (entget e1)))) (cadr (cdr (assoc 10 (entget e2))))))))
- (setq ent_Text (car ent_Texts))
- (setq ents (entget ent_Text))
- (setq pt (cdr (assoc 10 ents)))
- (setq h1 (cdr (assoc 40 ents)))
- (setq pt (list (car pt) (+ (cadr pt) h1) (last pt)))
- (setq str (cdr (assoc 1 ents)))
- (setq lay (cdr (assoc 8 ents)))
- (setq style (cdr (assoc 7 ents)))
- (repeat (1- (length ent_Texts))
- (setq ents (entget (nth i ent_Texts)))
- (setq str (strcat str "\n" (cdr (assoc 1 ents))))
- (setq i (1+ i))
- )
- (mapcar 'entdel ent_Texts)
- (MakeText pt str h lay style)
- )(defun main( / ss i ent_Texts h)
- (setq ss (ssget '((0 . "text"))))
- (setq i 0)
- (setq ent_Texts nil)
- (repeat (sslength ss)
- (setq ent_Texts (append ent_Texts (list (ssname ss i))))
- (setq i (1+ i))
- )
- (setq h (getreal "输入字高:"))
- (text->Mtext ent_Texts h)
- )
|