Hmmm..
Yes Mtext does seem problematic. But the short way works with many
other entity types (line, circle, arc, insert, text...), and not just with
optional data fields. Start points, insertion points, rotation angles, layers,
text data in text entities.... can all be changed by creating a short entity info
list containing just the reference ename field and the data to change.
(entmod (list (cons -1 ename)(cons 1 "newtext"))) when applied to an mtext
entity results in an mtext entity with a blank text field (1 . ""). AutoCAD
apparently ignores the new text specification.
Seems like an AutoCAD bug to me. But Mtext entities are complex and there
is an interrelationship between many of the fields. I created
a program to convert text entities to mtext entities and even needed to use the
100 fields AcDbEntity and AcDbMtext to get it to work.
I guess there are exceptions to every rule.
Doug
"Marc'Antonio Alessi" wrote in message news:EC220C76B737A01C300BE334304D0FD2@in.WebX.maYIadrTaRb...
> > It can be even shorter. There is no need to check for the existence of
> > the field. See Doug's reposnse below.
> >
>
> Frank, this is not fully true:
>
> 1 - yes I do not need check for the existence of the field
>
> 2 - in some occurrences I need to use the subst method
> to override the field
>
> (maybe when the field is not optional?)
>
> Marco
>
> see:
> >>> subst
> Comando: !e_data
> ((-1 . ) (0 . "MTEXT") (330 .
> 40080c10>)
> (5 . "BB6D") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
> "$LAY_TEXT_NORM") (62 . 253) (100 . "AcDbMText") (10 0.0 50.0 0.0) (40 .
> 40.0)
> (41 . 0.0) (71 . 4) (72 . 1) (1 . "OLDSTRING") (7 . "STANDARD") (210 0.0 0.0
> 1.0) (11 1.0 0.0 0.0) (42 . 252.0) (43 . 40.5563) (50 . 0.0) (73 . 1) (44 .
> 1.0))
>
> Comando: (entmod (subst (cons 1 "NEWSTRING") (assoc 1 e_data) e_data))
> ((-1 . ) (0 . "MTEXT") (330 .
> 40080c10>)
> (5 . "BB6D") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
> "$LAY_TEXT_NORM") (62 . 253) (100 . "AcDbMText") (10 0.0 50.0 0.0) (40 .
> 40.0)
> (41 . 0.0) (71 . 4) (72 . 1) (1 . "NEWSTRING") (7 . "STANDARD") (210 0.0 0.0
> 1.0) (11 1.0 0.0 0.0) (42 . 252.0) (43 . 40.5563) (50 . 0.0) (73 . 1) (44 .
> 1.0))
>
> Comando: (entget (cdr (assoc -1 e_data)))
> ((-1 . ) (0 . "MTEXT") (330 .
> 40080c10>)
> (5 . "BB6D") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
> "$LAY_TEXT_NORM") (62 . 253) (100 . "AcDbMText") (10 0.0 50.0 0.0) (40 .
> 40.0)
> (41 . 0.0) (71 . 4) (72 . 1) (1 . "NEWSTRING") (7 . "STANDARD") (210 0.0 0.0
> 1.0) (11 1.0 0.0 0.0) (42 . 264.0) (43 . 40.1421) (50 . 0.0) (73 . 1) (44 .
> 1.0))
>
> >>> (1 . "NEWSTRING")
>
>
> >>> (list ename field)
> Comando: !e_data
> ((-1 . ) (0 . "MTEXT") (330 .
> 40080c10>)
> (5 . "BB6E") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
> "$LAY_TEXT_NORM") (62 . 253) (100 . "AcDbMText") (10 0.0 100.0 0.0) (40 .
> 40.0)
> (41 . 0.0) (71 . 4) (72 . 1) (1 . "OLDSTRING") (7 . "STANDARD") (210 0.0 0.0
> 1.0) (11 1.0 0.0 0.0) (42 . 252.0) (43 . 40.5563) (50 . 0.0) (73 . 1) (44 .
> 1.0))
>
> Comando: (entmod (list (assoc -1 e_data) '(1 . "NEWSTRING") ))
> ((-1 . ) (1 . "NEWSTRING"))
>
> Comando: (entget (cdr (assoc -1 e_data)))
> ((-1 . ) (0 . "MTEXT") (330 .
> 40080c10>)
> (5 . "BB6E") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
> "$LAY_TEXT_NORM") (62 . 253) (100 . "AcDbMText") (10 0.0 100.0 0.0) (40 .
> 40.0)
> (41 . 0.0) (71 . 4) (72 . 1) (1 . "") (7 . "STANDARD") (210 0.0 0.0 1.0) (11
> 1.0 0.0 0.0) (42 . 0.0) (43 . 0.0) (50 . 0.0) (73 . 1) (44 . 1.0))
>
> >>> (1 . "")
>
>
>
>
>
>