Does any one know how to change properties of a Mtext?

Does any one know how to change properties of a Mtext?

Anonymous
Not applicable
1,859 Views
5 Replies
Message 1 of 6

Does any one know how to change properties of a Mtext?

Anonymous
Not applicable

I need to change specific properties of Mtext via lisp. The properties that I am getting from (entget(entlast)) includes the following data. I need to change some of the inputs when using the lisp. Does anyone know how I can do that?

 

((-1 . <Entity name: 1c0034b8990>) (0 . "MTEXT") (5 . "32749") (102 . "{ACAD_XDICTIONARY") (360 . <Entity name: 1c0034b89a0>) (102 . "}") (330 . <Entity name: 1bfb60dc9f0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "FTE-ELEC DETAILS") (62 . 4) (100 . "AcDbMText") (10 -34.3759 -154.35 0.0) (40 . 200.0) (41 . 15000.0) (46 . 0.0) (71 . 1) (72 . 5) (1 . "TITLE\\P \\PGENERAL\\P \\P\\pxi-3,l3,t3;A.\tLINE1\n\\PB.\tLINE 2 \n\\PC.\tLINE 3\\P\\pi0,l0,tz;\\PSPECIFIC\\P\\P\\pi-3,l3,t3;1.\tLINE 1\\P2.\tLINE 2\\P3.\tLINE 3\\P4.\tLINE 4") (7 . "FTE - Style") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0) (42 . 1421.01) (43 . 5214.46) (50 . 0.0) (73 . 1) (44 . 1.0))

0 Likes
Accepted solutions (1)
1,860 Views
5 Replies
Replies (5)
Message 2 of 6

scot-65
Advisor
Advisor
Accepted solution
Explore SETPROPERTYVALUE.
Use DUMPALLPROPERTIES as a guide.

Items such as text justify (called Attachment) can be discovered
when investigating thru the Properties palette and tinkering
with an existing MTEXT object.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 3 of 6

Kent1Cooper
Consultant
Consultant

The way to do that by way of entity data is with the (subst) and (entmod) and in some cases (entupd) AutoLisp functions.  Read about them in Help, and Search for examples of their use in the Customization Forum.  But you need to know what all those code numbers in the entity data list represent.  You can get that from the DXF reference for Mtext.

Kent Cooper, AIA
0 Likes
Message 4 of 6

hencoop
Advisor
Advisor

In some cases it is easier to change properties using Visual Lisp functions... in others it is more complex.  (Visual Lisp functions all begin with VL)

 

Try this to see the properties accessible via Visual Lisp:

(SETQ obj (VLAX-ENAME->VLA-OBJECT (ENTLAST)))
(VLAX-DUMP-OBJECT obj)

 

You can generally use (VLAX-PUT-PROPERTY <object> '<property name> <new value>) to change the property; however, points and some other things require additional code to give <new value> its required structure.  Those are more complex than modifying the association list that you got by using (ENTGET (ENTLAST)).

 

As @Kent1Cooper already advised, to modify the association list use (SUBST <new item> <old item> <association list>) and (ENTMOD <association list>) and (ENTUPD <entity name>) if neccessary to update the entity's display.

 

To see the book on these and other functions, type their name anywhere in the VLIDE, select it, right-click, select "Apropos Window..." in the popup, in the "Apropos results" window select the function name and pick the question mark icon.  The Autodesk help window will open to the discussion of the function and its use.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
Message 5 of 6

Sea-Haven
Mentor
Mentor

As you did not say what you wanted changed, use the vl-dump on mtext and you will see your text in the variable Textstring you will also see the control strings \\C is color \\p is paragraph etc 

 

You can change or add these codes so need to know what it is you want to do.

 

Example change numbers to red text to green.

0 Likes
Message 6 of 6

Anonymous
Not applicable

As you guys mentioned above I was able to do this simply by using (Setpropertyvalye (entlast) "Contents" "MY TEXT"). Thank you, everyone, for helping me out. 

0 Likes