I use the command 'LEADER' to draw leaders to text. I use multileader occasionally, but leader seems to work best in the situations I draft (unless I am using it incorrectly). My question is, when I draw a leader and go to add the leader landing, I am always eyeballing the angle to show it at. However I want the angle of the landing to be the angle of the line I am pointing the leader to or the dimension. Below is an example in which I would like to have the leader landing the same angle as the dimension or the red line. Is there any way to set that with the leader command or is that a multileader option to set?
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Ok, you have 3 entities. Leader, Text and Red Line.
So you have a text and a read line already, and you want to add a leader that matches the angle to a red line (why not to a text?)
BTW you have ACAD version?
@ВeekeeCZ wrote:Ok, you have 3 entities. Leader, Text and Red Line.
So you have a text and a read line already, and you want to add a leader that matches the angle to a red line (why not to a text?)
BTW you have ACAD version?
I guess if you look at it, it is only really 2 entities. The leader and text (OR red line) Having the leader landing match the angle of the text is what needs to be done utimately. I just saw the red line and that is what I thought of matching it to. If I want to get super specific and clean I usually will draw the leader at a point in space, add the second point nearest to the red line and then the 3rd point to another nearest point on the red line and then move the whole leader to where I need it and adjust the grip at the arrowhead. That is how I get around not eyeballing and avoid getting a weird looking angle. I have been drafting a long time so I can eyeball half decent, but if I am training someone new, it is all over the place. Hopefully that makes sense. Oh and Civil3d2023, but posted here since leader is more of an acad thing.
@ВeekeeCZ 's routine has angle-determination code with more capability than it needs, because it comes out of my Bisector.lsp routine which requires you to pick two straight objects, and sets variables related to the two of them separately, which is not needed here. I also have an AlignSnap.lsp routine which uses the same checking on a single selected object to get its angle, to which I have added the Leader part here:
(defun C:ALLA ; = Align Leader Landing Angle
(/ snang apert esel edata etype picknear path)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
); if
(setvar 'aperture apert)
(setvar 'snapang snang)
(setvar 'orthomode orth)
); defun
(setq snang (getvar 'snapang))
(setq apert (getvar 'aperture))
(setq orth (getvar 'orthomode))
(setvar 'aperture (getvar 'pickbox)); less likely to snap to wrong object
(while
(not
(and
(setq esel (entsel "\nSelect object to Align Leader landing angle with: "))
(setq
edata (entget (car esel))
etype (cdr (assoc 0 edata))
); setq
(wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,LEADER,HATCH,TEXT,MTEXT,INSERT,VIEWPORT,TRACE,SOLID,WIPEOUT,3DFACE,ATTDEF,AEC_WALL")
); and
); not
(prompt "\nNothing selected, or cannot Align Snap with that object --")
); while
(cond
((= etype "HATCH") (setvar 'snapang (cdr (assoc 52 edata))))
((wcmatch etype "*TEXT,INSERT,ATTDEF")
(setvar 'snapang (cdr (assoc 50 edata)))
); text/mtext/block/xref/attribute types
((wcmatch etype "MLINE,TRACE,SOLID,VIEWPORT,WIPEOUT,3DFACE,AEC_WALL")
(setq picknear (osnap (cadr esel) "nea"))
(setvar 'snapang (angle picknear (osnap picknear "end")))
); non-"curve" types with straight edges that can be Osnapped to
(T; for everything else
(setq
path (car esel)
picknear (osnap (cadr esel) "nea")
); setq
(setvar 'snapang
(angle
'(0 0 0)
(vlax-curve-getFirstDeriv path (vlax-curve-getParamAtPoint path picknear))
); angle
); setvar
); linear-curvilinear entity types
); cond - type of entity
(setvar 'orthomode 0)
(command "_.leader" pause pause)
(setvar 'orthomode 1)
(command pause "" "" "_none"); finish Leader
(setvar 'aperture apert)
(setvar 'snapang snang)
(setvar 'orthomode orth)
); defun
It assumes you always want a two-leg Leader as in your image. It aligns the SNAPANG System Variable with the straight thing you pick on, starts a LEADER command with ORTHO turned off for the first two picks, then turns ORTHO on for the third pick [yes, you could draw the landing part perpendicular to that direction, but I leave it to you to do the result you want], and ends the command. It then resets System Variables that it changed in the process.
Regards @kzD1219
Try this code. Select the aligned text and attach an Mleader to it. I particularly prefer to work with multileader, because they are more manageable and dynamic.
(defun c:Mla (/ selb tx ang p1 p2 objx selb)
(vl-load-com)
(while
(setq selb (car (entsel "\nSelect text Aligned...:")))
(setq tx (cdr (assoc 1 (entget selb)))
ht (cdr (assoc 40 (entget selb)))
ang (cdr (assoc 50 (entget selb)))
p2 (cdr (assoc 10 (entget selb)))
)
(if (and
(setq p1 (getpoint "\nEspecify Arrowhead Location: "))
)
(progn
(setq objx
(vlax-invoke
(vlax-get (vla-get-ActiveDocument (vlax-get-acad-object))
(if (= 1 (getvar 'CVPORT))
'PaperSpace
'ModelSpace
)
)
'AddMLeader
(append p1 p2)
0
)
)
(vla-put-textstring objx tx)
(vla-put-TextRotation objx ang)
(vla-put-LandingGap objx 0.5)
(vla-put-Dogleglength objx ht)
(vla-put-textjustify objx 2)
(vla-put-ArrowheadSize objx ht)
(vla-put-TextHeight objx ht)
(vla-put-TextLineSpacingStyle objx 2.0)
(vla-put-TextLineSpacingFactor objx 1.0)
(vla-put-TextleftAttachmentType objx 5.0)
;;
(vla-put-TextRightAttachmentType objx 5.0)
;;
(vla-update objx)
(entdel selb)
)
)
)
(princ)
)
Carlos Calderon G
>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.
Regards @kzD1219
I made some edits in the code above (text height, arrow length, landing distance alineado con el angulo del texto)
Carlos Calderon G
>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.
@Kent1Cooper wrote:@ВeekeeCZ 's routine has angle-determination code with more capability than it needs, because it comes out of my Bisector.lsp routine which requires you to pick two straight objects, and sets variables related to the two of them separately, which is not needed here. I also have an AlignSnap.lsp routine which uses the same checking on a single selected object to get its angle, to which I have added the Leader part here:
(defun C:ALLA ; = Align Leader Landing Angle
(/ snang apert esel edata etype picknear path)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
); if
(setvar 'aperture apert)
(setvar 'snapang snang)
(setvar 'orthomode orth)
); defun
(setq snang (getvar 'snapang))
(setq apert (getvar 'aperture))
(setq orth (getvar 'orthomode))
(setvar 'aperture (getvar 'pickbox)); less likely to snap to wrong object
(while
(not
(and
(setq esel (entsel "\nSelect object to Align Leader landing angle with: "))
(setq
edata (entget (car esel))
etype (cdr (assoc 0 edata))
); setq
(wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,LEADER,HATCH,TEXT,MTEXT,INSERT,VIEWPORT,TRACE,SOLID,WIPEOUT,3DFACE,ATTDEF,AEC_WALL")
); and
); not
(prompt "\nNothing selected, or cannot Align Snap with that object --")
); while
(cond
((= etype "HATCH") (setvar 'snapang (cdr (assoc 52 edata))))
((wcmatch etype "*TEXT,INSERT,ATTDEF")
(setvar 'snapang (cdr (assoc 50 edata)))
); text/mtext/block/xref/attribute types
((wcmatch etype "MLINE,TRACE,SOLID,VIEWPORT,WIPEOUT,3DFACE,AEC_WALL")
(setq picknear (osnap (cadr esel) "nea"))
(setvar 'snapang (angle picknear (osnap picknear "end")))
); non-"curve" types with straight edges that can be Osnapped to
(T; for everything else
(setq
path (car esel)
picknear (osnap (cadr esel) "nea")
); setq
(setvar 'snapang
(angle
'(0 0 0)
(vlax-curve-getFirstDeriv path (vlax-curve-getParamAtPoint path picknear))
); angle
); setvar
); linear-curvilinear entity types
); cond - type of entity
(setvar 'orthomode 0)
(command "_.leader" pause pause)
(setvar 'orthomode 1)
(command pause "" "" "_none"); finish Leader
(setvar 'aperture apert)
(setvar 'snapang snang)
(setvar 'orthomode orth)
); defun
It assumes you always want a two-leg Leader as in your image. It aligns the SNAPANG System Variable with the straight thing you pick on, starts a LEADER command with ORTHO turned off for the first two picks, then turns ORTHO on for the third pick [yes, you could draw the landing part perpendicular to that direction, but I leave it to you to do the result you want], and ends the command. It then resets System Variables that it changed in the process.
After testing this out, this is the solution that I was hoping for. Works great, just got to remember to use it now instead of eyeballing. Much appreciated!
@calderg1000 wrote:Regards @kzD1219
Try this code. Select the aligned text and attach an Mleader to it. I particularly prefer to work with multileader, because they are more manageable and dynamic.
(defun c:Mla (/ selb tx ang p1 p2 objx selb)
(vl-load-com)
(while
(setq selb (car (entsel "\nSelect text Aligned...:")))
(setq tx (cdr (assoc 1 (entget selb)))
ht (cdr (assoc 40 (entget selb)))
ang (cdr (assoc 50 (entget selb)))
p2 (cdr (assoc 10 (entget selb)))
)
(if (and
(setq p1 (getpoint "\nEspecify Arrowhead Location: "))
)
(progn
(setq objx
(vlax-invoke
(vlax-get (vla-get-ActiveDocument (vlax-get-acad-object))
(if (= 1 (getvar 'CVPORT))
'PaperSpace
'ModelSpace
)
)
'AddMLeader
(append p1 p2)
0
)
)
(vla-put-textstring objx tx)
(vla-put-TextRotation objx ang)
(vla-put-LandingGap objx 0.5)
(vla-put-Dogleglength objx ht)
(vla-put-textjustify objx 2)
(vla-put-ArrowheadSize objx ht)
(vla-put-TextHeight objx ht)
(vla-put-TextLineSpacingStyle objx 2.0)
(vla-put-TextLineSpacingFactor objx 1.0)
(vla-put-TextleftAttachmentType objx 5.0)
;;
(vla-put-TextRightAttachmentType objx 5.0)
;;
(vla-update objx)
(entdel selb)
)
)
)
(princ)
)
I would much prefer to work with multileaders as well, but with the edits we do and the way our information is shown, good old leaders with mtext seems to work much better. We are also using different styles of text and scales so using multileaders gets a little messy when trying to edit text styles, however I am certainly going to test this out further to see if it is beneficial to switch. Most of the cases I would need to draft leaders it would be to point a dimension to a certain location because there is no space allowed. Thank you for coming up with this and I do plan to give it a try with what we draft.
Can't find what you're looking for? Ask the community or share your knowledge.