Leader Spline Lisp Fix/Addition

Leader Spline Lisp Fix/Addition

JohnC_ISM
Collaborator Collaborator
3,891 Views
25 Replies
Message 1 of 26

Leader Spline Lisp Fix/Addition

JohnC_ISM
Collaborator
Collaborator

we have a lisp called LDS that creates a splined line with arrow head for callouts.

 

is there a line someone could add in to make it automatically spline? 

 

 

also, a bug i just noticed that if my midpoint selection is off then it snaps to the base corner instead of the midpoint of the arrow head. not a issue really but something i noticed. 

 

 

 

 

(gc)
(COMMAND "COLOR" "BYLAYER")
(defun c:11(/ p1 p2 p3 p4)
(command "color" "CYAN")
(gc)
(setvar "cmdecho" 0)
(command "color" "CYAN")
(while (setq p1(getpoint "\nLeader start: "))
(initget 1)
(setq p2(getpoint p1 "\nNext point: "))
(if (> (distance p1 p2) (* (getvar "dimasz")(getvar "dimscale")))
(progn
(setq p3(polar p1 (angle p1 p2)
(* (getvar "dimasz")(getvar "dimscale")))
)
(setq p4(polar p3 (+ (angle p1 p2) (* 1.5 pi))
(/ (* (getvar "dimasz")(getvar "dimscale")) 6.0))
)
(command "solid" p4 (polar p4 (+ (angle p1 p2) (* 0.5 pi))
(/ (* (getvar "dimasz")(getvar "dimscale")) 3.0)) p1 p1 ""
)
(command "line" p3 p2 "")
)
(command "line" p1 p2 "")
)
(setq ss1(ssadd))
(setq ss1(entlast))
(setq p1 p2)
(setq ss(ssadd))
(prompt " add ok")
(while (setq p2(getpoint p1 "\nNext point: "))
(command "line" p1 p2 "")
(setq tmp(entlast))
(ssadd tmp ss)
(setq p1 p2)
)
(command "pedit" ss1 "y" "j" ss "" "s" "")
)
(gc)
(princ)
(gc)
(COMMAND "COLOR" "BYLAYER")
(setq ss1 nil ss nil)
(princ "done.")
(princ)
)
;;
;;
;; *********** Local Error Trap Function ************
;;
(defun myerror (sxx)
(if (= sxx nil)
(setq sxx "console break")
); end if
(if (not (member sxx '("console break" "Function cancelled")))
(princ (strcat "\nError: " sxx))
); end if
(if (= (member sxx '("console break" "Function cancelled")))
(progn
(prompt "\nError: Break...")
(setvar "MENUECHO" 0)
(setvar "HIGHLIGHT" 1)
(setvar "SORTENTS" 1)
(setvar "ATTDIA" 0); No Attribute Dialog Boxes, please
(setvar "ATTREQ" 1); Attributes Required
(setvar "CMDDIA" 1); Plot command dialog on
); end progn
); end if
(setvars); reset all old system variables
(setvar "CMDECHO" 0)
(setq sxx nil)
(princ)
); end function err
(setq olderr *error* *error* myerror)
;;
;; Get Old System Variables
;;
(defun getvars ()
(setq osm (getvar "OSMODE"))
;; add any other system variables here
); end function
(defun setvars ()
(setvar "OSMODE" osm)
;; reset any other system variables here
); end function
;; *************** end of error trapping *****************
;;

0 Likes
Accepted solutions (1)
3,892 Views
25 Replies
Replies (25)
Message 2 of 26

ronjonp
Advisor
Advisor

What version of AutoCAD are you on? This should be done with an MLEADER style set to splined segment. See attached.

0 Likes
Message 3 of 26

Kent1Cooper
Consultant
Consultant

Not necessarily a Mleader Style.  You can also use a Leader.  Start the QLEADER command [LE is the alias], and choose the Settings option:

SplineLeaderOption.PNG

That Closed-filled arrowhead would be similar to your effect, but there are all the other choices.  Note the number-of-points option, see the other tabs for options about whether and how Mtext content is to be included, etc.

 

One huge advantage of using a Leader/Qleader/Mleader over your approach is that the arrowhead's direction will adjust automatically if you alter the path of it.  And it will be a quicker procedure than yours with its multiple steps.

Kent Cooper, AIA
Message 4 of 26

ronjonp
Advisor
Advisor

@Kent1Cooper  Is there an advantage of using a qleader over mleader? I honestly have not used a qleader since mleaders were introduced in AutoCAD 2008 or so.

0 Likes
Message 5 of 26

Kent1Cooper
Consultant
Consultant

@ronjonp wrote:

@Kent1Cooper  Is there an advantage to using a qleader over mleader? ....Qleaders.PNG


 

Kent Cooper, AIA
0 Likes
Message 6 of 26

ronjonp
Advisor
Advisor

Interesting. How did you add all those extra leaders to that octopus? 🙂

0 Likes
Message 7 of 26

Kent1Cooper
Consultant
Consultant

@ronjonp wrote:

.... How did you add all those extra leaders to that octopus?


 

They're just QLEADER Leaders, as described in the second half of the image.  The disadvantage compared to MultiLeaders, if considered one, is that they are independent of the Mtext, not linked to or associated with it, which is why they can be indicators from any part of it.

 

I usually do this kind of thing with a "stack" of notes in a single Mtext, with blank lines between "entries," so they remain nicely lined up, and Qleaders pointing from all the entries to the various things they describe or identify.

Kent Cooper, AIA
0 Likes
Message 8 of 26

JohnC_ISM
Collaborator
Collaborator

Well i tried the mleader because you can make it spline but the angle of the line when you end it has a little tail that sometime curve the wrong way or the curve of the line moves around wrong

0 Likes
Message 9 of 26

JohnC_ISM
Collaborator
Collaborator

Ill check out the qleader style and see if its what I’m looking for. The PLINE in my lisp makes it way easier to make sure the ending is exactly where i want it. I was just tryna add that one more step in the lisp to auto spline it. But ill try this 

0 Likes
Message 10 of 26

dlanorh
Advisor
Advisor

@JohnC_ISM wrote:

Well i tried the mleader because you can make it spline but the angle of the line when you end it has a little tail that sometime curve the wrong way or the curve of the line moves around wrong


The little tail is the landing, and can be removed by unchecking the "Automatically include Landing" check box on the Leader Structure Tab of the MLeader Style Manager. Both MLeaders and QLeaders can be splined.

 

I am not one of the robots you're looking for

0 Likes
Message 11 of 26

dlanorh
Advisor
Advisor

Forgot to mention that you can change both Mleader and QLeader settings in lisp (QLeader if you have Express Tools installed).

I am not one of the robots you're looking for

0 Likes
Message 12 of 26

ronjonp
Advisor
Advisor

@Kent1Cooper wrote:

@ronjonp wrote:

.... How did you add all those extra leaders to that octopus?


 

They're just QLEADER Leaders, as described in the second half of the image.  The disadvantage compared to MultiLeaders, if considered one, is that they are independent of the Mtext, not linked to or associated with it, which is why they can be indicators from any part of it.

 

I usually do this kind of thing with a "stack" of notes in a single Mtext, with blank lines between "entries," so they remain nicely lined up, and Qleaders pointing from all the entries to the various things they describe or identify.


Gotcha .. I thought all those leaders were 'attached' to the qleader. One thing that I really liked when mleaders came out was the ability to easily line them up using MLEADERALIGN.

2019-08-26_9-43-43.gif

0 Likes
Message 13 of 26

ronjonp
Advisor
Advisor

@JohnC_ISM wrote:

Well i tried the mleader because you can make it spline but the angle of the line when you end it has a little tail that sometime curve the wrong way or the curve of the line moves around wrong


Can you post a sample drawing of how you're using these? Custom leaders with arrowheads that are not 'attached' to the leader makes for horrible editing later on.

0 Likes
Message 14 of 26

john.uhden
Mentor
Mentor

AAUGH!  What, are you still using R10?

There is a LEADER object.  And one of its properties is COORDINATES.  You can get them and replace them.

John F. Uhden

0 Likes
Message 15 of 26

Kent1Cooper
Consultant
Consultant
Accepted solution

@JohnC_ISM wrote:

... The PLINE in my lisp makes it way easier to make sure the ending is exactly where i want it. ....


 

That's no easier with a Polyline than it is with a QLEADER.  Here I left the blips on so you can see where I picked to draw them, and that when more than one is off the same part of the Mtext, using Snap makes their tail ends coincide exactly:

Qleader.PNG

SO MANY other advantage of Leaders [whether made with LEADER or QLEADER or MLEADER] over a Polyline with a non-associated arrowhead, primarily the automatic aim adjustment of the arrowhead with an altered Leader "path" as already mentioned, but also others, for example:
Qleader2.PNG

Kent Cooper, AIA
0 Likes
Message 16 of 26

JohnC_ISM
Collaborator
Collaborator

QLEADER worked way better than MLEADER just because it had that lil tail when using multi 

 

quick worked thanks. 

0 Likes
Message 17 of 26

JohnC_ISM
Collaborator
Collaborator

heres my next problem i just ran into. the qleader style resets each drawing i jump into. 

 

anyway to make the settings permanent no matter whose drawing i open?

0 Likes
Message 18 of 26

Kent1Cooper
Consultant
Consultant

@JohnC_ISM wrote:

.... the qleader style resets each drawing i jump into. 

anyway to make the settings permanent no matter whose drawing i open?


 

I'd like that, too.  It's been a while since I tried to figure that out, but I wasn't able to -- it's not saved in something as easy as System Variables.  Maybe the Registry?  Setting it up that way in drawing Template files at least gets it for you in all New drawings based on those Templates.

 

I've become accustomed to just calling up LE and the Settings option, and picking No annotation associated, Spline format, and limit to 4 points.  [I can still do other kinds when I want to, using the Leader and Mleader commands instead of Qleader.]

Kent Cooper, AIA
0 Likes
Message 19 of 26

ronjonp
Advisor
Advisor

This might be where an mleader wins :). Create a style then you can put it in your template or import using design center.

 

Try this style attached.

0 Likes
Message 20 of 26

dlanorh
Advisor
Advisor

@Kent1Cooper wrote:

@JohnC_ISM wrote:

.... the qleader style resets each drawing i jump into. 

anyway to make the settings permanent no matter whose drawing i open?


 

I'd like that, too.  It's been a while since I tried to figure that out, but I wasn't able to -- it's not saved in something as easy as System Variables.  Maybe the Registry? 


 

(setq x_rec (dictsearch (namedobjdict) "AcadDim"))

I am not one of the robots you're looking for

0 Likes