Changing MTEXT with using code

Changing MTEXT with using code

PDACTL
Enthusiast Enthusiast
169 Views
5 Replies
Message 1 of 6

Changing MTEXT with using code

PDACTL
Enthusiast
Enthusiast

I have an old command (from when the MTEXT was introduced) which set group 41 to 0 to remove word wrapping if the bounding box was too small for the contents.

 

Since I switched to AutoCAD 2023 this no longer works - changing DXF group 41 with lisp has no visual effect.

 

The old "width" property is no longer there, but there's a "defined width" which is read only.

 

I can only change it by dragging the ruler on the MTEXT editor.

 

How can achieve this with code in 2023?

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

EnM4st3r
Collaborator
Collaborator
Accepted solution

you can change the defined widht only if "Columns" is set to none. I have found no DXF group that controls that and also no activex property to change that. But you can change it with 'setpropertyvalue' so: (setpropertyvalue ent "ColumnType" 0)


This example sets the width to 0.

(defun c:foo (/ ent)
  (setq ent (car (entsel)))
  (setpropertyvalue ent "ColumnType" 0)
  (vla-put-width (vlax-ename->vla-object ent) 0)
)

 

0 Likes
Message 3 of 6

PDACTL
Enthusiast
Enthusiast

Perfect!

 

Thank you.

0 Likes
Message 4 of 6

swilson2AH6Y6
Contributor
Contributor

Maybe <<THIS>> code to set No Columns and 0 width from BlackBox.

0 Likes
Message 5 of 6

komondormrex
Mentor
Mentor

@PDACTL 

Even simler

(entmod (append (entget (car (entsel))) '((75 . 0) (41 . 0))))

 

Message 6 of 6

Kent1Cooper
Consultant
Consultant

If you don't want word wrapping, is there a reason to be using Mtext?  Unless you need internal formatting like changing the color or font of only part of it, or stacked fractions, then the simplest thing of all:  just draw it as plain Text in the first place.

[I was going to suggest EXPLODE for existing Mtext, but if word wrapping is involved, it will become separate Text objects for each line.  You'd need to widen the box, or set its width to zero, to get it in one line first.]

Kent Cooper, AIA
0 Likes