Text to Multileader

This routine will allow you to select either an MTEXT or DTEXT (single line text) object and then create a multileader from its contents on the current layer and the current multileader style.

  • Here’s how:
  • AM <enter> to start Add Multileader
  • Select text object (MTEXT or DTEXT)
  • Place the multileader as you normally would…

~enjoy

 

 

Links to other multileader routines:

https://autocadtips.wordpress.com/2011/06/17/autolisp-add-leader-to-mtext-or-dtext/

https://autocadtips.wordpress.com/2012/03/12/add-leader-to-text-make-multileader/

https://autocadtips.wordpress.com/2012/03/12/autolisp-covert-dtext-mtext-to-multileaders/


;;; By RonJon
;;; Found at http://www.cadtutor.net/forum/showthread.php?41822-changing-text-mtext-to-multileaders...
(defun c:am (/ newleader pt1 pt2 ss txt x w rjp-getbbwdth)
  (vl-load-com)
  (defun rjp-getbbwdth (obj / out ll ur)
    (vla-getboundingbox obj 'll 'ur)
    (setq out (mapcar 'vlax-safearray->list (list ll ur)))
    (distance (car out) (list (caadr out) (cadar out)))
  )
  (if (setq ss (ssget '((0 . "*TEXT"))))
    (progn (setq txt (apply
		       'strcat
		       (mapcar
			 'cdr
			 (vl-sort
			   (mapcar '(lambda (x)
				      (cons (vlax-get x 'insertionpoint)
					    (strcat (vlax-get x 'textstring) " ")
				      )
				    )
				   (setq
				     ss	(mapcar
					  'vlax-ename->vla-object
					  (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
					)
				   )
			   )
			   (function (lambda (y1 y2) (< (cadr (car y2)) (cadr (car y1))))
			   )
			 )
		       )
		     )
		 w   (car (vl-sort (mapcar 'rjp-getbbwdth ss) '>))
		 txt (apply 'strcat
			    (mapcar 'chr (reverse (cdr (reverse (vl-string->list txt)))))
		     )
	   )
	   (mapcar 'vla-delete ss)
    )
  )
  (if (and (setq pt1 (getpoint "\nSpecify leader arrowhead location: "))
	   (setq pt2 (getpoint pt1 "\nSpecify landing location: "))
      )
    (progn (command "._MLEADER" pt1 pt2 "")
	   (setq newleader (vlax-ename->vla-object (entlast)))
	   (vla-put-textstring newleader txt)
	   (vla-put-textwidth newleader w)
    )
  )
  (princ)
)
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, AutoLISP: Modify, AutoLISP: Text, Leaders, Modifying. Bookmark the permalink.

10 Responses to Text to Multileader

  1. Brian says:

    It certainly works, but in my case, the text goes microscopic and the text positioning is strange (the leader “underlines” the text). Also, if the mtext wraps into a multi line paragraph, it will make it one continuous line.

  2. Randell says:

    My Mleader has the landing underlining all my first line of text if I lead to the right but not to the left??

    • AutoCAD Tips says:

      This is an annoying default setting in AutoCAD.
      To fix this, you need to adjust the Multileader style
      Use the command MLEADERSTYLE and then in the dialog box that appears, select the mleader style to be changed, and then select “Modify”

      Click on the “Content” tab in the dialog box and then in the lower left area there is a “Leader connection” area.
      “Horizontal attachment” should be checked. Then make sure that both “Left attachment” and “Right attachment” have the same setting applied to them. In your case i think that they should both be set to “Middle of top line”
      ~Greg

      • Randell says:

        Thanks! That was it. I do appreciate your answer!!
        Autodesk is more than a little annoying with ridiculous defaults like this.

  3. r robinson says:

    Hello – We need to add alphanumerically listed Notes/Text to drawings with the number/letter being in a box or circle. We have not found any easy way to do this in AutoCad 13. If you know how to do this it would be very appreciated. RR

  4. Octavian says:

    hello, it does not work for me, im using a mac version of autocad 2013, what can be wrong?

  5. Michael says:

    Hello, Everything works fine except in my 2012, I need to enter the text in order for it to be placed (Yes, I did select my text first.) Any suggestions?

    Thank you!

  6. Michael says:

    EDIT for clarification:
    When I select the text, it does disappear (understandably), but I am prompted to Enter Text to complete the routine. In other words, it doesn’t keep my original text like in the little gifs posted.
    Any suggestions? Maybe a setting in my mleader settings or in text settings? (I have followed your suggestions for MLEADER settings.)
    Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s