Here is a sub routine that will take a text string as an argument, open the mtext dialog
and return the edited text. You can then create the mtext object with your specifications.
;;; FUNCTION
;;; Use ddedit box to edit a text string.
;;;
;;; ARGUMENTS
;;; txt = the text string
;;;
;;; USAGE
;;; mtext_edit
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Charles Alan Butler
;;; ab2draft@TampaBay.rr.com
;;;
;;; VERSION
;;; 1.0 May. 11, 2005 (defun mtext_edit (txt / entlist ent)
(if (entmake (list
'(0 . "MTEXT")
'(100 . "AcDbEntity")
'(100 . "AcDbMText")
(cons 10 '(0 0 0)) ; insert point
(cons 7 (getvar "TextStyle")) ; Current Style
(cons 40 (getvar "TextSize")) ; Current height
(cons 41 0) ; 0 Width = no wrap
(cons 71 1) ; 1=Top Left Attachment point
(cons 1 txt) ; Text String
)
)
(progn
(setq ent (entlast))
(command "._ddedit" ent "")
(setq txt (cdr (assoc 1 (entget ent))))
(entdel ent)
txt
)
)
)
(defun c:test(/ newtext)
(setq newtext (mtext_edit "This is a test string."))
)
And here is the dtext version.
;;; FUNCTION
;;; Use ddedit box to edit a text string.
;;;
;;; ARGUMENTS
;;; txt = the text string
;;;
;;; USAGE
;;; text_edit
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Charles Alan Butler
;;; ab2draft@TampaBay.rr.com
;;;
;;; VERSION
;;; 1.0 Oct. 06, 2004
(defun text_edit (txt / entlist ent)
(if (entmake
(list
'(0 . "TEXT")
(cons 10 '(0 0))
(cons 40 1)
(cons 7 (getvar "TEXTSTYLE"))
(cons 1 txt) ; Text String
)
)
(progn
(setq ent (entlast))
(command "._ddedit" ent "")
(setq txt (cdr (assoc 1 (entget ent))))
(entdel ent)
txt
)
)
)
(defun c:test(/ newtext)
(setq newtext (text_edit "This is a test string."))
)