Author Topic: Is there a tool to compact Mtext boxes? - SOLVED!  (Read 26151 times)

0 Members and 1 Guest are viewing this topic.

JGA

  • Mosquito
  • Posts: 10
Is there a tool to compact Mtext boxes? - SOLVED!
« on: June 22, 2011, 05:46:47 AM »
Hi, I was wondering if anyone has developed or knows of a tool that can help me.
I've inherited a project where the original drafter was inexperienced in AutoCAD.
One of the problems is that the width of mtext boxes have not been compacted down to the width of the text.

It would be impractical for me to open each mtext entry & double click on the ruler end, so I wondered if there is a routine that can do this with a selection of text in a drawing.

My own LISP experience is limited to creating shortcuts for regular commands (ZE-Zoom Extents etc.), so this is beyond my current limits.
Thanks in advance for anyone who can help, or point me in the right direction.

PS - One great tool I found was StripMtext from Steve Doman and Joe Burke at http://cadabyss.wordpress.com/. It removes additional formatting from Mtext. It is superb!
« Last Edit: June 27, 2011, 11:04:50 AM by JGA »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Is there a tool to compact Mtext boxes?
« Reply #2 on: June 22, 2011, 06:29:23 AM »
Without wanting to cause problems/stir the waters etc...

Can someone explain the advantages of having a text box compacted to fit the width of a text?

Thanks
Thanks for explaining the word "many" to me, it means a lot.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Is there a tool to compact Mtext boxes?
« Reply #3 on: June 22, 2011, 06:36:38 AM »
I thought something like this, but upon testing, I can't seem to get it to work  :-(

Code: [Select]
(defun c:test ( / ss i e )
  (if (setq ss (ssget "_:L" '((0 . "MTEXT"))))
    (repeat (setq i (sslength ss))
      (setq e (entget (ssname ss (setq i (1- i)))))
      (entmod (subst (cons 41 (cdr (assoc 42 e))) (assoc 41 e) e))
    )
  )
  (princ)
)

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Is there a tool to compact Mtext boxes?
« Reply #4 on: June 22, 2011, 07:28:43 AM »
Without wanting to cause problems/stir the waters etc...

Can someone explain the advantages of having a text box compacted to fit the width of a text?

Thanks

The user then has to grip edit the each and every piece of text to change the width to get the text to fit into the detail box or viewport.  It is just a big PITA.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Is there a tool to compact Mtext boxes?
« Reply #5 on: June 22, 2011, 08:25:39 AM »
You could use QSELECT to select all MTEXT entities then change their properties all at once.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Nibster

  • Guest
Re: Is there a tool to compact Mtext boxes?
« Reply #6 on: June 22, 2011, 08:43:41 AM »
You could use QSELECT to select all MTEXT entities then change their properties all at once.
that could mess up the formatting if some text was wider than the new width value.  sounds like autowrap wasn't used if the box is wider than the contents.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Is there a tool to compact Mtext boxes?
« Reply #7 on: June 22, 2011, 09:19:39 AM »
If you use carriage returns instead of the autowrapper (based on MText width), you could just set the width to zero.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Is there a tool to compact Mtext boxes?
« Reply #8 on: June 22, 2011, 09:22:11 AM »
If you use carriage returns instead of the autowrapper (based on MText width), you could just set the width to zero.
And that my friend would get you a lotto of grief in my office.  That was one reason a user was fired for that.

But hey that is just how we roll with out limited, word of mouth, subject to change with the wind, cad standards.  :roll:
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Is there a tool to compact Mtext boxes?
« Reply #9 on: June 22, 2011, 09:29:59 AM »
If you use carriage returns instead of the autowrapper (based on MText width), you could just set the width to zero.
And that my friend would get you a lotto of grief in my office.  That was one reason a user was fired for that.

But hey that is just how we roll with out limited, word of mouth, subject to change with the wind, cad standards.  :roll:
Ouch. I just don't see the benefit of an MText width. Then again, most of my non c3d labels are single lines of MText - only using MText over DText because I can use a background mask when needed. Nothing irritates me more than turning on a background mask for a piece of text (especially a road name) and suddenly half my drawing is blacked out because some retard decided to create the MText with a gigantic width.

Here's what I use for dealing with widths:

Change width of selected text:
Code: [Select]
(defun c:WD (/ ss wd)
  ;; Change width of selected MText and MultiLeader objects
  ;; Alan J. Thompson, 11.05.09
  (if (and (setq ss (ssget "_:L" '((0 . "MTEXT,MULTILEADER"))))
           (setq wd (initget 4)
                 wd (cond ((getdist "\nWidth <0.0>: "))
                          (0.)
                    )
           )
      )
    (progn
      (vlax-for x (setq ss (vla-get-activeselectionset
                             (cond (*AcadDoc*)
                                   ((setq *AcadDoc* (vla-get-activedocument
                                                      (vlax-get-acad-object)
                                                    )
                                    )
                                   )
                             )
                           )
                  )
        (vl-catch-all-apply
          (function vlax-put-property)
          (list x
                (cond ((eq (vla-get-objectname x) "AcDbMText") 'Width)
                      ((eq (vla-get-objectname x) "AcDbMLeader") 'TextWidth)
                )
                wd
          )
        )
      )
      (vla-delete ss)
    )
  )
  (princ)
)

My zero width by default MText macro (I can right-click on the first pick and it will resume normal MText behavior for when I'm typing notes in paperspace and want the use of wordwrap.
Code: [Select]
; mtext with 0 width
(defun c:T (/ pt)
  (initdia)
  (command "_.mtext")
  (if (setq pt (getpoint "\nSpecify insertion point <First corner>: "))
    (command "_non" pt "_W" 0.)
  )
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Is there a tool to compact Mtext boxes?
« Reply #10 on: June 22, 2011, 10:01:05 AM »
I thought something like this, but upon testing, I can't seem to get it to work  :-(

Code: [Select]
(defun c:test ( / ss i e )
  (if (setq ss (ssget "_:L" '((0 . "MTEXT"))))
    (repeat (setq i (sslength ss))
      (setq e (entget (ssname ss (setq i (1- i)))))
      (entmod (subst (cons 41 (cdr (assoc 42 e))) (assoc 41 e) e))
    )
  )
  (princ)
)

Works here Lee  :?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Is there a tool to compact Mtext boxes?
« Reply #11 on: June 22, 2011, 10:10:53 AM »
I thought something like this, but upon testing, I can't seem to get it to work  :-(

Code: [Select]
(defun c:test ( / ss i e )
  (if (setq ss (ssget "_:L" '((0 . "MTEXT"))))
    (repeat (setq i (sslength ss))
      (setq e (entget (ssname ss (setq i (1- i)))))
      (entmod (subst (cons 41 (cdr (assoc 42 e))) (assoc 41 e) e))
    )
  )
  (princ)
)

Works here Lee  :?
Works in 11 for the width, but not the height.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Is there a tool to compact Mtext boxes?
« Reply #12 on: June 22, 2011, 10:13:39 AM »
If you use carriage returns instead of the autowrapper (based on MText width), you could just set the width to zero.
And that my friend would get you a lotto of grief in my office.  That was one reason a user was fired for that.

But hey that is just how we roll with out limited, word of mouth, subject to change with the wind, cad standards.  :roll:
Ouch. I just don't see the benefit of an MText width. Then again, most of my non c3d labels are single lines of MText - only using MText over DText because I can use a background mask when needed. Nothing irritates me more than turning on a background mask for a piece of text (especially a road name) and suddenly half my drawing is blacked out because some retard decided to create the MText with a gigantic width.
that user had other issues more serious than cad standards.  But not following cad standards was one of the items on the list.  Your example is good one why we can and need to be different in our cad standards.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Is there a tool to compact Mtext boxes?
« Reply #13 on: June 22, 2011, 10:19:57 AM »
If you use carriage returns instead of the autowrapper (based on MText width), you could just set the width to zero.
And that my friend would get you a lotto of grief in my office.  That was one reason a user was fired for that.

But hey that is just how we roll with out limited, word of mouth, subject to change with the wind, cad standards.  :roll:
Ouch. I just don't see the benefit of an MText width. Then again, most of my non c3d labels are single lines of MText - only using MText over DText because I can use a background mask when needed. Nothing irritates me more than turning on a background mask for a piece of text (especially a road name) and suddenly half my drawing is blacked out because some retard decided to create the MText with a gigantic width.
that user had other issues more serious than cad standards.  But not following cad standards was one of the items on the list.  Your example is good one why we can and need to be different in our cad standards.
That's a different situation. If I was told I had to have a width because of standards, I might argue the 'point', but in the end I'd obviously comply...unless you saw things my way. Mostly it just irritates the hell out of me when people use the width and are incredibly sloppy about it.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Is there a tool to compact Mtext boxes?
« Reply #14 on: June 22, 2011, 10:22:00 AM »
I thought something like this, but upon testing, I can't seem to get it to work  :-(

Code: [Select]
(defun c:test ( / ss i e )
  (if (setq ss (ssget "_:L" '((0 . "MTEXT"))))
    (repeat (setq i (sslength ss))
      (setq e (entget (ssname ss (setq i (1- i)))))
      (entmod (subst (cons 41 (cdr (assoc 42 e))) (assoc 41 e) e))
    )
  )
  (princ)
)

Works here Lee  :?
Works in 11 for the width, but not the height.

This works for me (height and width)

Code: [Select]
(defun c:test (/ ss i e)
  (if (setq ss (ssget "_:L" '((0 . "MTEXT"))))
    (repeat (setq i (sslength ss))
      (setq e (entget (ssname ss (setq i (1- i)))))
      (entmod (setq e (subst (cons 41 (cdr (assoc 42 e))) (assoc 41 e) e)))
      (entmod (subst (cons 46 (cdr (assoc 43 e))) (assoc 46 e) e))
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC