TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Dave M on December 17, 2018, 11:47:23 AM

Title: Mtext/Multileader Text Shrinkwrap
Post by: Dave M on December 17, 2018, 11:47:23 AM
I am working on a project that has a lot of Mtext and Multileaders with text and the box widths and heights are all over the place.  Normally, it wouldn't be a problem, but when you mask them it is.  Does anyone have a routine that would essentially "shrinkwrap" the boundary to fit the text? Both width and height?


Thanks in advance!



Title: Re: Mtext/Multileader Text Shrinkwrap
Post by: ribarm on December 17, 2018, 12:57:15 PM
My first thought and what I'd do is use (textbox) function to obtain bounding box points of text, or (vla-getboundingbox) method to get bb points and then I'd create new rectangle while (entdel) existing one that's buggy...
Title: Re: Mtext/Multileader Text Shrinkwrap
Post by: roy_043 on December 17, 2018, 02:26:47 PM
AFAIK the textbox function cannot handle mtext formatting. And the boundingbox won't give the required values here. Look at gc 42 and 43 in the entity list instead.
Title: Re: Mtext/Multileader Text Shrinkwrap
Post by: ribarm on December 17, 2018, 02:33:52 PM
What's wrong with TEXTMASK.LSP - Express Tools or TCIRCLE command - ACETTXT.LSP - Express Tools?
Title: Re: Mtext/Multileader Text Shrinkwrap
Post by: ronjonp on December 17, 2018, 03:09:14 PM
Have you seen this for MTEXT?
http://www.theswamp.org/index.php?topic=38691.msg438005#msg438005
or
http://www.theswamp.org/index.php?topic=38691.msg437960#msg437960
Title: Re: Mtext/Multileader Text Shrinkwrap
Post by: Dave M on December 17, 2018, 04:19:55 PM
What's wrong with TEXTMASK.LSP - Express Tools or TCIRCLE command - ACETTXT.LSP - Express Tools?


Maybe I didn't make myself clear enough.  When the original drafter placed the mtext/mleaders, they placed them using rectangles much larger than needed.  I want to shrink them to the extents of the actual text.
Title: Re: Mtext/Multileader Text Shrinkwrap
Post by: roy_043 on December 18, 2018, 04:07:55 AM
Code - Auto/Visual Lisp: [Select]
  1. ; (MtextShrinkBox (car (entsel)))
  2. (defun MtextShrinkBox (enm / elst)
  3.   (setq elst (entget enm))
  4.   (entmod
  5.     (subst
  6.       (cons 41 (cdr (assoc 42 elst))) ; Box width.
  7.       (assoc 41 elst)
  8.       (subst
  9.         ; (cons 46 (cdr (assoc 43 elst))) ; Box height.
  10.         '(46 . 0.0)
  11.         (assoc 46 elst)
  12.         elst
  13.       )
  14.     )
  15.   )
  16. )