Jump to content

Edit for Mleader Text


jonathann3891

Recommended Posts

Can this lisp be edited to work on mleader text boxes?

 

It shirinks the text box to the minimum requirement to cover the text.

 

(defun c:MTL (/ sset en el ymt nmt mtwidth mtcont)
(setq sset (ai_aselect))
(if (null sset) 
 (progn
 (princ "\nNo objects selected.")
 (exit)
 )
)
(setq COUNT 0)
(setq ymt 0)
(setq nmt 0)
(if (/= sset nil)(setq EN (ssname sset COUNT))(setq EN nil))
(WHILE (/= EN nil)
 (setq mtcont nil)
 (setq nel nil)
 (setq EL (entget EN))
 (if (= (cdr (assoc 0 EL)) "MTEXT")
  (progn
   (setq mtwidth (* (cdr (assoc 42 el))1.015))
   (setq EL (subst (cons 41 mtwidth) (assoc 41 EL) EL))
   (progn
    (setq nel el)
    (while (/= (assoc 3 nel) nil)
     (setq mtcont
      (if (= mtcont nil)
       (cdr (assoc 3 nel))
       (strcat mtcont (cdr (assoc 3 nel)))
      )
     )
     (setq nel (vl-remove (assoc 3 nel) nel))
    )
    (if (= mtcont nil)
     (setq mtcont (cdr (assoc 1 nel)))
     (setq mtcont (strcat mtcont (cdr (assoc 1 nel))))
    )
    (setq el nel)
   )
   (setq EL (subst (cons 1 mtcont) (assoc 1 EL) EL))
   (if (= (cdr (assoc 90 EL)) 2)
    (setq el (vl-remove (assoc 90 EL) EL))
   )
   (entmod EL)
   (entupd en)
   (setq el (entget en '("ACAD")))
   (if (/= (assoc -3 el) nil)
    (progn
     (setq oheight (assoc 1040 (cdadr (assoc -3 el))))
     (setq nheight (cons 1040 (cdr (assoc 43 el))))
     (setq n-3 (list (cons -3 (list (subst nheight oheight (cadr (assoc -3 el)))))))
     (setq el (vl-remove (assoc -3 el) el))
     (setq el (append el n-3))
    )
   )
   (entdel (cdr (assoc -1 el)))
   (entmake el)
   (setq COUNT (1+ COUNT))
   (setq EN (SSNAME sset COUNT))
   (setq ymt (1+ ymt))
  )
  (progn
   (setq COUNT (1+ COUNT))
   (setq EN (SSNAME sset COUNT))
   (setq nmt (1+ nmt))
  )
 )
)
(prompt (strcat "\n" (itoa ymt) " Mtext object(s) were resized, and " (itoa nmt) " object(s) were not Mtext."))
(princ)
)

Edited by jonathann3891
Link to comment
Share on other sites

The only problem with the code is that it will shrink the horizontal limits to fix the text, but it stretches the vertical limits.

Link to comment
Share on other sites

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...