Jump to content

Change MText Width (after width has been changed))


Recommended Posts

Posted

I found some code by kent1cooper here

 

(defun C:MTW ; = MText Width
  (/ ss wf n mt)
  (if
    (and
      (setq ss (ssget "_:L" '((0 . "MTEXT"))))
      (setq wf (getreal "\nWidth Factor to apply: "))
    ); and
    (repeat (setq n (sslength ss)); then
      (setq mt (ssname ss (setq n (1- n))))
      (setpropertyvalue mt "Contents"
        (strcat "{\\W" (rtos wf 2) ";" (getpropertyvalue mt "Contents") "}")
      ); setpropertyvalue
    ); repeat
  ); if
  (princ)
); defun

 

This works great.... BUT once the width has been changed it no longer works.

image.thumb.png.a2829b80960ee1710230e9419d7702e9.png

Is it a simple fix to change the width after it has been changed? Ideally select multiple and not have to pick the dropdown to change.

image.png.5176b39386db29c19b65c78ba9bd27d5.png

 

If you have a style that has a defined width, the routine works until you change it to something else.

If you run STRIPMTEXT on a string, it resets something so the change text code works again.

 

 

 

 

Posted (edited)

The code is adding a width string to the text. These characters are hidden but will show up if you click on the text and look at it in the properties menu, or via the LISP line:

(assoc 1 (entget(car(entsel))))

 

In the code it adds {\\W'wf'; to the string where wf is the width factor

 

Something like

{\\W0.8;Here is a text string}

If you run the code again, it will add another width factor to the text string... but won't remove the first, so you get something like this:

{\\W0.5;{\\W0.8;Here is a text string}} - noting that the new text width is applied and then the first one is applied.. result is you only see what was applied first. Need to remove this formatting to the text string before applying a new one.

 

You might also have issues if other text formatting is used, such as underlined, italics, bold...

 

For width you might be able to amend Lee Macs Unformat LISP to just unformat the width portion:

https://lee-mac.com/unformatstring.html

In these text strings replace with just 'W'

ACcFfHLlOopQTW

 

and here 

ACcFfHLlOoPpQSTW

change to SW

 

... and then apply the new width formatting from your LISP

 

.. though CAD is off so not tested - all part of the fun for you!

 

 

 

...if Lee Mac is passing through, feel free to correct me, though many years later I am just about understanding some of your codes.

Edited by Steven P

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...