<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Ajust Mtext width in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375633#M97373</link>
    <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just found what I was looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you anyway&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun mip-mtext-wrap-BB (en / el SetHandles CheckHandles sclst)
 
(defun GetAnnoScales (e / dict lst rewind res)
 
 (if (and e 
          (setq dict (cdr (assoc 360 (entget e))))
          (setq lst (dictsearch dict "AcDbContextDataManager"))
          (setq lst (dictsearch (cdr (assoc -1 lst)) "ACDB_ANNOTATIONSCALES"))
          (setq dict (cdr (assoc -1 lst)))
     )
     (progn 
       (setq rewind t)
       (while (setq lst (dictnext dict rewind))
         (setq e (cdr (assoc 340 lst))
               res (cons (cdr (assoc 300 (entget e))) res)
               rewind nil
         ) 
       ) 
     )
 )
 (reverse res)
)
 
(defun CheckHandles (e / dict lst rewind nlst d42 d43 n p ptlst)
 
 (if (and e
          (setq dict (cdr (assoc 360 (entget e))))
          (setq lst (dictsearch dict "AcDbContextDataManager"))
          (setq lst (dictsearch (cdr (assoc -1 lst)) "ACDB_ANNOTATIONSCALES"))
          (setq dict (cdr (assoc -1 lst)))
     )
     (progn
       (setq rewind t)
       (while (setq lst (dictnext dict rewind))
         (setq nlst (cons lst nlst)
               rewind nil
         ) 
       )
       (cond ((= 1 (length nlst)))
             (t (foreach x nlst 
                   (setq d42 (cdr (assoc 42 x)) 
                         d43 (cdr (assoc 43 x))
                         n (/ d42 d43)
                         lst (cons n lst)
                         p (cdr (assoc 11 x))
                         ptlst (cons p ptlst))
                )
                (and
                  (vl-every '(lambda (x) (equal n x 1e-4)) lst)
                  (vl-every '(lambda (x) (equal p x 1e-4)) ptlst)
                )
             ) 
       )
     )
 )
)
 
(defun SetHandles (lst / oldlst charwidth ht pat)
 
  (setq lst (entget (cdr(assoc -1 lst)) '("ACAD")))
  (setq charwidth (* (cdr (assoc 42 lst)) 1.05) ;_1.035
        ht (cdr (assoc 43 lst))
        lst (subst (cons 41 charwidth) (assoc 41 lst) lst)
        lst (subst (cons 46 ht) (assoc 46 lst) lst)
        lst (if (assoc 75 lst)
                (subst (cons 75 0) (assoc 75 0) lst)
                (append lst (list(cons 75 0)))
            )
  )
  
 (if (and
       (setq pat (assoc -3 lst))
       (eq "ACAD" (caadr pat))
     )
     (progn
       (if (assoc 46 lst)
           (setq pat '(-3 ("ACAD")))
           (setq pat (cons -3 (list (subst (cons 1040 ht) (assoc 1040 (cdadr pat)) (cadr pat))))) 
       )
       (setq lst (subst pat (assoc -3 lst) lst))
     )
 )
 
 (setq lst (entmod lst))
 
)
 

(if (= (cdr (assoc 0 (setq EL (entget en '("*"))))) "MTEXT") 
    (cond ((and (setq sclst (GetAnnoScales en)) (CheckHandles en))
           (vl-cmdf "._chprop" en "" "_Annotative" "_No" "") 
           (SetHandles el)
           (vl-cmdf "._chprop" en "" "_Annotative" "_Yes" "")
           (foreach x sclst
             (vl-cmdf "._objectscale" en "" "_Add" x "")
           )
          )
          ((not (GetAnnoScales en))
           (SetHandles el)
          )
          (t nil)
    ) 
)
 
)
 
(defun C:&amp;lt;Test1 (/ ss i)

  (and (setq ss (ssget "_:L" '((0 . "MTEXT"))))
       (repeat (setq i (sslength ss))
               (mip-mtext-wrap-BB (ssname ss (setq i (1- i))))
       )
       (setq ss nil)
  )

)&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Nov 2018 08:56:13 GMT</pubDate>
    <dc:creator>C.Utzinger</dc:creator>
    <dc:date>2018-11-02T08:56:13Z</dc:date>
    <item>
      <title>Ajust Mtext width</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375399#M97371</link>
      <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;I found a lot of routines to Change the Mtext width to 0, but I'm looking for one that just ajust the width like in the DWG example attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Routine im using for the Moment:&lt;/P&gt;&lt;PRE&gt;(defun c:&amp;lt;test1 (/ ss acDoc i e)

  (if (setq ss (ssget "_:L" '((0 . "MTEXT"))))    
      (repeat (setq i (sslength ss))
        (setq e (entget (ssname ss (setq i (1- i))))
              e (append e '((75 . 0)))
              e (subst '(41 . 0.0) (assoc 41 e) e)
        )
        (entmod e)
      )
  )
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for help&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 06:27:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375399#M97371</guid>
      <dc:creator>C.Utzinger</dc:creator>
      <dc:date>2018-11-02T06:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Ajust Mtext width</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375570#M97372</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like this:&lt;/P&gt;
&lt;PRE&gt;(defun c:test1 (/ w ss i e)
  (if
    (and (setq w (getdist "\nText width: "))
         (setq ss (ssget "_:L" '((0 . "MTEXT"))))
    )
     (repeat (setq i (sslength ss))
       (setq e (entget (ssname ss (setq i (1- i)))))
       (entmod (subst (cons 41 w) (assoc 41 e) e))
     )
  )
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;You can also use setpropertyvalue instead of entmod.&lt;/P&gt;
&lt;PRE&gt;(defun c:test2 (/ w ss i e)
  (if
    (and (setq w (getdist "\nText width: "))
         (setq ss (ssget "_:L" '((0 . "MTEXT"))))
    )
     (repeat (setq i (sslength ss))
       (setq e (ssname ss (setq i (1- i))))
       (setpropertyvalue e "Width" w)
     )
  )
  (princ)
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Nov 2018 08:48:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375570#M97372</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-11-02T08:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Ajust Mtext width</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375633#M97373</link>
      <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just found what I was looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you anyway&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun mip-mtext-wrap-BB (en / el SetHandles CheckHandles sclst)
 
(defun GetAnnoScales (e / dict lst rewind res)
 
 (if (and e 
          (setq dict (cdr (assoc 360 (entget e))))
          (setq lst (dictsearch dict "AcDbContextDataManager"))
          (setq lst (dictsearch (cdr (assoc -1 lst)) "ACDB_ANNOTATIONSCALES"))
          (setq dict (cdr (assoc -1 lst)))
     )
     (progn 
       (setq rewind t)
       (while (setq lst (dictnext dict rewind))
         (setq e (cdr (assoc 340 lst))
               res (cons (cdr (assoc 300 (entget e))) res)
               rewind nil
         ) 
       ) 
     )
 )
 (reverse res)
)
 
(defun CheckHandles (e / dict lst rewind nlst d42 d43 n p ptlst)
 
 (if (and e
          (setq dict (cdr (assoc 360 (entget e))))
          (setq lst (dictsearch dict "AcDbContextDataManager"))
          (setq lst (dictsearch (cdr (assoc -1 lst)) "ACDB_ANNOTATIONSCALES"))
          (setq dict (cdr (assoc -1 lst)))
     )
     (progn
       (setq rewind t)
       (while (setq lst (dictnext dict rewind))
         (setq nlst (cons lst nlst)
               rewind nil
         ) 
       )
       (cond ((= 1 (length nlst)))
             (t (foreach x nlst 
                   (setq d42 (cdr (assoc 42 x)) 
                         d43 (cdr (assoc 43 x))
                         n (/ d42 d43)
                         lst (cons n lst)
                         p (cdr (assoc 11 x))
                         ptlst (cons p ptlst))
                )
                (and
                  (vl-every '(lambda (x) (equal n x 1e-4)) lst)
                  (vl-every '(lambda (x) (equal p x 1e-4)) ptlst)
                )
             ) 
       )
     )
 )
)
 
(defun SetHandles (lst / oldlst charwidth ht pat)
 
  (setq lst (entget (cdr(assoc -1 lst)) '("ACAD")))
  (setq charwidth (* (cdr (assoc 42 lst)) 1.05) ;_1.035
        ht (cdr (assoc 43 lst))
        lst (subst (cons 41 charwidth) (assoc 41 lst) lst)
        lst (subst (cons 46 ht) (assoc 46 lst) lst)
        lst (if (assoc 75 lst)
                (subst (cons 75 0) (assoc 75 0) lst)
                (append lst (list(cons 75 0)))
            )
  )
  
 (if (and
       (setq pat (assoc -3 lst))
       (eq "ACAD" (caadr pat))
     )
     (progn
       (if (assoc 46 lst)
           (setq pat '(-3 ("ACAD")))
           (setq pat (cons -3 (list (subst (cons 1040 ht) (assoc 1040 (cdadr pat)) (cadr pat))))) 
       )
       (setq lst (subst pat (assoc -3 lst) lst))
     )
 )
 
 (setq lst (entmod lst))
 
)
 

(if (= (cdr (assoc 0 (setq EL (entget en '("*"))))) "MTEXT") 
    (cond ((and (setq sclst (GetAnnoScales en)) (CheckHandles en))
           (vl-cmdf "._chprop" en "" "_Annotative" "_No" "") 
           (SetHandles el)
           (vl-cmdf "._chprop" en "" "_Annotative" "_Yes" "")
           (foreach x sclst
             (vl-cmdf "._objectscale" en "" "_Add" x "")
           )
          )
          ((not (GetAnnoScales en))
           (SetHandles el)
          )
          (t nil)
    ) 
)
 
)
 
(defun C:&amp;lt;Test1 (/ ss i)

  (and (setq ss (ssget "_:L" '((0 . "MTEXT"))))
       (repeat (setq i (sslength ss))
               (mip-mtext-wrap-BB (ssname ss (setq i (1- i))))
       )
       (setq ss nil)
  )

)&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Nov 2018 08:56:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375633#M97373</guid>
      <dc:creator>C.Utzinger</dc:creator>
      <dc:date>2018-11-02T08:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Ajust Mtext width</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375685#M97374</link>
      <description>&lt;P&gt;It would be nice of you if you reveal the source and noted the author(s).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The origin source is probably&amp;nbsp;&lt;A href="http://www.theswamp.org/index.php?topic=38691.msg438005#msg438005" target="_blank"&gt;HERE&lt;/A&gt;&amp;nbsp;at&amp;nbsp;theswamp.org&lt;/P&gt;
&lt;P&gt;Nice find though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 09:17:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375685#M97374</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2018-11-02T09:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Ajust Mtext width</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375694#M97375</link>
      <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;Yes you're&amp;nbsp; right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found it here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://autocadtips1.com/2011/08/13/autolisp-text-box-width/" target="_blank"&gt;https://autocadtips1.com/2011/08/13/autolisp-text-box-width/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I cleaned it and eliminated some "progn"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 09:19:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ajust-mtext-width/m-p/8375694#M97375</guid>
      <dc:creator>C.Utzinger</dc:creator>
      <dc:date>2018-11-02T09:19:56Z</dc:date>
    </item>
  </channel>
</rss>

