Discussion:
MTEXT to TEXT-Taking care of Justification maintaining Bot.Left Corner of MTEXT
(too old to reply)
Joe Burke
2004-02-11 11:22:09 UTC
Permalink
MNRaghu,

Given your example, all you need do is explode the mtext objects to text.

I think the lisp program you posted is intended to deal with mtext objects which
contain multiple lines of text. Take a few lines and convert it into a single text
object. Which obviously, explode mtext doesn't do. But it is pretty smart in terms
how it explodes mtext to text.

I think there are easier ways to do what that program does. Basically take advantage
of how ACAD explodes mtext. Here's a quickie example. No need to deal with
justification issues as far as I've tested.

;; 2/10/2004
;; selection set order returned by ssget "P"
;; after explode is line 1, line 2, etc.

(defun c:Mtext2Text ( / ent vobj ss firstobj idx newstr str )
(setq ent (car (entsel "\nSelect mtext: ")))
;; Expode method doesn't apply to mtext objects
(command "_explode" ent)
(setq ss (ssget "P"))
(setq firstobj (vlax-ename->vla-object (ssname ss 0)))
(setq newstr "")
(setq idx 0)
(repeat (sslength ss)
(setq vobj (vlax-ename->vla-object (ssname ss idx)))
(setq str (vlax-get vobj 'TextString))
(setq newstr (strcat newstr str))
(setq idx (1+ idx))
)
(vlax-put firstobj 'TextString newstr)
(setq ss (ssdel (ssname ss 0) ss))
(command "_erase" ss "")
(princ)
) ;end

Joe Burke
Hi all,
I have the program as given below, downloaded from a magazine (cadence or cadalyst?
I have forgotten, excuse me) website, also given below.
This program does not take care of the justfications set in MTEXT, before
converting the same into TEXT.
Enclosed bmp file shows a glipse of the effect of conversion of 'TOP_CENTER'
justified MTEXT into TEXT.
The TEXT is hardcoded to take the justification of Bottom-Left.
Have anybody tried a program that can convert MTEXT into TEXT with the following
a) Maintain the bottom left corner position of Original MTEXT entity when converted
to TEXT, what ever the justification of MTEXT is.
b) Justification should be Bottom Left corner only (as in the given program)
I tried to get the bottom left corner of the MTEXT by using the GETBOUNDING_BOX
function, but did not work for me. It gave varied bounding points with varying
justifications of MTEXT.
Could any one help me in this aspect?
Thanks in advance,
MNRaghu
;this program is taken from cadalyst (or cadence? I have forgot, excuse me)
magazine website.
;Tip1455.LSP: MMTEXT.LSP Mtext to Text (c)1998, Jim Houser
(defun C:MTT (/ en ent nent lyr ipt tsz txt sty elv spc ts pt pty
npty ptx ptz npt)
(setq en (car (entsel "\nSelect MTEXT to change to regular text "))
ent (entget en)
nent (car ent)
)
(setq lyr (assoc 8 ent)
ipt (assoc 10 ent)
tsz (assoc 40 ent)
txt (assoc 1 ent)
sty (assoc 7 ent)
elv (assoc 210 ent)
spc (assoc 67 ent)
)
(setq ts (cdr tsz)
pt (cdr ipt)
pty (cadr pt)
npty (- pty ts)
ptx (car pt)
ptz (caddr pt)
npt (list ptx npty ptz)
ipt (cons 10 npt)
)
(setq nent
(list nent (cons 0 "TEXT")
(cons 100 "AcDbEntity")
spc
lyr
(cons 100 "AcDbText")
ipt
tsz
txt
(cons 50 0.0)
(cons 41 1.0)
(cons 51 0.0)
sty
(cons 71 0)
(cons 72 0)
(cons 11 (list 0.0 0.0 0.0))
elv
(cons 73 0)
))
(entdel en)
(entmake nent)
(princ)
)
RaghuMN
2004-02-12 03:51:57 UTC
Permalink
That was a simple and effective solution Joe.

I generally handle single line MTEXTs.

Just 'exploding' did the job what I wanted.

The program you gave works fine with multiline Mtexts.

Thanks,

MNRaghu
Joe Burke
2004-02-12 06:11:24 UTC
Permalink
MNRaghu,

You're welcome. Glad I could help.

Joe Burke
Post by RaghuMN
That was a simple and effective solution Joe.
I generally handle single line MTEXTs.
Just 'exploding' did the job what I wanted.
The program you gave works fine with multiline Mtexts.
Thanks,
MNRaghu
Loading...