MLeader - Text option

MLeader - Text option

andres_bonilla
Enthusiast Enthusiast
1,327 Views
11 Replies
Message 1 of 12

MLeader - Text option

andres_bonilla
Enthusiast
Enthusiast

Hi everyone! 

 

As for the Mleaders options using a text, it is possible to create a vertical line that follows the text as I indicated in the image on the right inside the green rectangle?

 

Thank you in advance for your help.

 

MLeader T1.jpg

0 Likes
Accepted solutions (1)
1,328 Views
11 Replies
Replies (11)
Message 2 of 12

CodeDing
Advisor
Advisor

@andres_bonilla ,

 

Is it possible? Yes.

Is it easily done? No.

Would it look good? Yes.

Is it practical? Not in my opinion.

 

While I do think that what you're requesting would have a clean finished appearance (compared to a text frame) I do not believe that the effort of developing such a lisp, implementing the routine, running the command, and maintaining the leaders (in the instances where they need moved / stretched / text updated) would be a practical idea to implement into AutoCAD. For something as simple as what you request (in appearance, not in execution) it would create a lot of heartache to maintain. Something like that should be deferred to our built-in abilities in AutoCAD such as the Text Frame. 

 

I'm not trying to be the downer, but I just wanted to voice where I believe the practicality of the request would fail. If you absolutely NEED this to be accomplished, you will definitely find a way (I would probably try my hand at a dynamic block first).

 

Best,

~DD

0 Likes
Message 3 of 12

Sea-Haven
Mentor
Mentor

Its the sort of thing that CIV3D "Styles" does where you have like 20 items to fill in so get the desired result. There is probably not the demand for a specific leader customisation style for Autodesk to justify doing it but never know.

0 Likes
Message 4 of 12

hak_vz
Advisor
Advisor

Try this code. It needs some polishing but will work for most of cases.

 

(defun c:MLL () (MLL))
;creates sideline to mleader text
;Author hak_vz 
;https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556
;09.17.2020
(defun MLL ( / e p1 p2 p3 p4 lst ty mt ent todel *error*)
(defun *error* ()
 (setvar 'cmdecho 1)
 (princ)
 )
(setq e (car (entsel "\nSelect mleader to add sideline >")))
(setvar 'cmdecho 0)
(setq p1 (cdr (assoc 10 (entget e))))
(setq p2 (mapcar '+ p1 (list 3 0 0)))
(setq lst (entlast) clst lst)
(command "copy" e "" '(0 0 0) '(0 0 0))
(command "explode" (entlast))
(while (setq clst (entnext clst))
	(setq ty (cdr (assoc 0 (entget clst))))
	(if (not (eq ty "MTEXT")) (entdel clst))
)
(setq mt (entnext lst) cmt mt)
(command "tcircle" mt "" "" "R" "V")
(command "explode" (entlast))
(while (setq mt (entnext mt))
(setq ent (entget mt))
(setq p3 (cdr (assoc 10 ent)))
(setq p4 (cdr (assoc 11 ent)))
(setq int (inters p1 p2 p3 p4 T))
(if (not int) (setq todel (cons mt todel)))
)
(foreach del todel
(entdel del)
)
(entdel cmt)
(setvar 'cmdecho 1)
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 12

ВeekeeCZ
Consultant
Consultant

If that's not one of the options served by default MLEADER dialog, as it's not, we cannot add this option anyhow.

While you can use some tricks but it will always be some sort of compromise.

 

Z9E3zK5E_0-1600335424220.png

 

0 Likes
Message 6 of 12

andres_bonilla
Enthusiast
Enthusiast

Thank you very much for your valuable contribution, I'm going to copy and create a routine and try to test it, could you please confirm what is the command that executes it?

 

Have a great day! 

0 Likes
Message 7 of 12

andres_bonilla
Enthusiast
Enthusiast

Thank you very much for your answer, indeed, it is not easy but I will try to prove your example.

 

Have a good day! 🙂

0 Likes
Message 8 of 12

hak_vz
Advisor
Advisor

@andres_bonilla wrote:

Thank you very much for your valuable contribution, I'm going to copy and create a routine and try to test it, could you please confirm what is the command that executes it?

 

Have a great day! 


Save a lisp code into a file with extension .lsp. Load it with acad command APPLoad. To execute run MLL.

It requests that you already have MLEADERS created. If will create a line on the left side to MTEXT. Before running it create new layer with line with and color defined (I didn't set it in a script).

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 9 of 12

andres_bonilla
Enthusiast
Enthusiast

Thank you, 

 

I just tried the routine and it doesn't work, when selecting the MLeader this message appears: 

<Entity name: BA9DBC50>

 

and then what happens is that it duplicates the MLeader but in the copy it eliminates the arrow.

 

Thank you for your comments.

0 Likes
Message 10 of 12

hak_vz
Advisor
Advisor

Now it will work, I hope.

 

(defun c:MLL () (MLL))
;creates sideline to mleader text
;Author hak_vz 
;https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556
;09.17.2020
(defun MLL ( / e p1 p2 p3 p4 lst ty mt ent todel *error* tc)
(defun *error* ()
 (setvar 'cmdecho 1)
 (princ)
 )
(defun tc (/ ss)
(if (not bns_tcircle) (load "acettxt.lsp"))
(setq ss (ssget "_L"))
(bns_tcircle ss "Variable" "Rectangles" nil 0.35)
)



(setq e (car (entsel "\nSelect mleader to add sideline >")))
(setvar 'cmdecho 0)
(setq p1 (cdr (assoc 10 (entget e))))
(setq p2 (mapcar '+ p1 (list 3 0 0)))
(setq lst (entlast) clst lst)
(command "copy" e "" '(0 0 0) '(0 0 0))
(command "explode" (entlast))
(while (setq clst (entnext clst))
	(setq ty (cdr (assoc 0 (entget clst))))
	(if (not (eq ty "MTEXT")) (entdel clst))
)
(setq mt (entnext lst) cmt mt)
(tc)
(command "explode" (entlast))
(while (setq mt (entnext mt))
(setq ent (entget mt))
(setq p3 (cdr (assoc 10 ent)))
(setq p4 (cdr (assoc 11 ent)))
(setq int (inters p1 p2 p3 p4 T))
(if (not int) (setq todel (cons mt todel)))
)
(foreach del todel
(entdel del)
)
(entdel cmt)
(setvar 'cmdecho 1)
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 11 of 12

hak_vz
Advisor
Advisor
Accepted solution

@andres_bonilla  Here is another version that adds string "|" in front or back to every line and squeezes text so that sideline don't look dashed. Ofcoures it can't be used on centered text for obvious reasons, but it will produce good result for most of situations.

 

 

 

(defun c:MLLL () (MLLL))
;creates sideline to mleader text
;Author hak_vz 
;https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556
;09.17.2020
(defun MLLL ( / eo txt tlist string_to_list)
(defun string_to_list ( str del / pos )
	(if (setq pos (vl-string-search del str))
		(cons (substr str 1 pos) (string_to_list (substr str (+ pos 1 (strlen del))) del))
		(list str)
	)
)
(setq eo (vlax-ename->vla-object (car (entsel "\nSelect mleader to add sideline >"))))
(setq txt (vlax-get eo 'TextString))
(setq txt (strcat "| " txt))
(setq tlist (string_to_list txt "\\P"))
(setq txt (car tlist) tlist (cdr tlist))
(foreach te tlist (setq txt (strcat txt (strcat "\\P| " te))))
(vlax-put eo 'TextString txt)
(vlax-put eo 'TextLineSpacingFactor 0.75)

(princ)
)


(defun c:MLLR () (MLLR))
;creates sideline to mleader text
;Author hak_vz 
;https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556
;09.17.2020
(defun MLLR ( / eo txt tlist string_to_list)
(defun string_to_list ( str del / pos )
	(if (setq pos (vl-string-search del str))
		(cons (substr str 1 pos) (string_to_list (substr str (+ pos 1 (strlen del))) del))
		(list str)
	)
)
(setq eo (vlax-ename->vla-object (car (entsel "\nSelect mleader to add sideline >"))))
(setq txt (vlax-get eo 'TextString))
(setq tlist (string_to_list txt "\\P"))
(setq txt "")
(foreach te tlist (setq txt (strcat txt (strcat te " | \\P"))))
(vlax-put eo 'TextString txt)
(vlax-put eo 'TextLineSpacingFactor 0.75)

(princ)
)

 

 

 

Untitled.png

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 12 of 12

andres_bonilla
Enthusiast
Enthusiast

Thank you very much for your great contribution, the routine works very well, and it will be very helpful in developing the information within the plans.

 

The best for you, always! 🙂 

0 Likes