AutoLISP: Covert DTEXT & MTEXT to Multileaders

The previous routine only works with MTEXT objects. This routine, however, works with both MTEXT and DTEXT objects and even makes the process easier.

Here’s how:

  • MTLE <enter> to start
  • Select the Text object(s)
  • Specify where the end point (arrow) of the leader should go.

(defun c:mlte (/) (c:MLeaderToExistingtext))
(defun c:MLeaderToExistingtext (/)
    ;;Select the text/mtext objects
       (null (setq ss1 (ssget ":S" '((0 . "text,mtext")))))
       (= 0 (setq ssl (sslength ss1)))
     nil				;nothing selected
       Textobj	(vlax-ename->vla-object (ssname ss1 0))
       ActSpace	(if (= 0 (getvar "cvport"))
		    (vla-get-activedocument (vlax-get-acad-object))
		    (vla-get-activedocument (vlax-get-acad-object))
       StartPt	(getpoint "\nPick location for point of arrow head: ")
       txt	(vla-get-TextString Textobj)

		(vla-get-insertionpoint textobj)
		(vlax-variant-value TextPt)
		(vlax-safearray->list TextPt)
		  '(0 . 5)
		(vlax-safearray-fill ptlist (append StartPt TextPt))
     (vla-put-textstring mlobj txt)
     (vla-delete Textobj)


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, Text. Bookmark the permalink.

9 Responses to AutoLISP: Covert DTEXT & MTEXT to Multileaders

  1. kevgb says:

    Hi Greg
    I keep getting the following error message!

    ; error: no function definition: VLAX-ENAME->VLA-OBJECT


    • AutoCAD Tips says:

      Thanks for the heads-up.
      I have updated the code
      The code was missing (vl-load-com)
      This loads the ability for Visual Lisp functions.

      Keep in mind that this is a common issue with code that you may find online. It doesn’t hurt to add this to any routine where you see a warning that mentions VLA-object…


  2. zarko says:

    MTLE to start
    Select the Text object(s) ???

    Finally works with MLTE , command not MTLE !!!!

  3. alex says:

    Can’t use with other ucs.

  4. Pingback: Text to Multileader | AutoCAD Tips

  5. marita says:

    How to do this with multiple text objects, keeping justification, rotation and position? Please help

  6. VASILE CHIPER says:


Leave a Reply

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

You are commenting using your 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 )

Connecting to %s