Leader Lisp
Leader Lisp
(OP)
Greetings All,
I'm updating some old lisp routines and one of them is a routine that draws a leader by picking points, drawing lines among those points and instering an arrow block at the original point. I'd rather have people just draw a normal leader but the learning curve is rather steep here (we have old schooler's) so the intent is to rewrite the existing lisp without anyone knowing there were any changes.
The old lisp lets you pick the first point then as many points as needed until you hit enter or cancel. The problem I'm having is the furthest I've been able to get it is the first and second point. I assume a WHILE command would continue the points but can't figure out where it should be inserted.
Here's my current code:
and here's the WHILE code from the old lisp:
If that code is used in the leader command it errors and starts a regular leader entity.
Thanks,
Keith
I'm updating some old lisp routines and one of them is a routine that draws a leader by picking points, drawing lines among those points and instering an arrow block at the original point. I'd rather have people just draw a normal leader but the learning curve is rather steep here (we have old schooler's) so the intent is to rewrite the existing lisp without anyone knowing there were any changes.
The old lisp lets you pick the first point then as many points as needed until you hit enter or cancel. The problem I'm having is the furthest I've been able to get it is the first and second point. I assume a WHILE command would continue the points but can't figure out where it should be inserted.
Here's my current code:
CODE
(defun C:AL (/ pt1 pt2)
(command "_.LAYER" "_S" "DIMEN" "")
(setq pt1 (getpoint "\nStart of leader: ")
pt2 (getpoint pt1 "\nTo point: "))
(command "_.LEADER" pt1 pt2 "_Annotation" "" "n")
)
(command "_.LAYER" "_S" "DIMEN" "")
(setq pt1 (getpoint "\nStart of leader: ")
pt2 (getpoint pt1 "\nTo point: "))
(command "_.LEADER" pt1 pt2 "_Annotation" "" "n")
)
and here's the WHILE code from the old lisp:
CODE
(while (setq pt2 (getpoint pt2 "\n To point: "))
(command pt2)) (command "")
(command pt2)) (command "")
If that code is used in the leader command it errors and starts a regular leader entity.
Thanks,
Keith
RE: Leader Lisp
Here's a partial solution, it doesn't show the leader if multiple poimts are picked, se what you think..
(defun C:ldr ()
(setq Pt1 (getpoint "\nSelect leader start point: "))
(command "leader" Pt1)
(while (setq Pt1 (getpoint Pt1 "Next point: "))
(command Pt1)
)
(command "_Annotation" "" "_N")
(princ)
)
RE: Leader Lisp
My lisp is a bit rusty, how could we incorporate your idea of using a pline?
RE: Leader Lisp
(defun C:ldr ()
(setvar "CMDECHO" 0);disable command prompts
(setq Pt1 (getpoint "\nSelect leader start point: "))
(setq PtList (list Pt1));list of 1 point
(command "pline" Pt1);;start pline command with first point
(while (setq Pt1 (getpoint "\nNext point: "))
(command Pt1);;draw next point of polyline)
(setq ptList (cons Pt1 PtList));;add point to list
)
(command "");end pline command
(setq ptList (reverse PtList));reverse so first point at front
(entdel (entlast));delete pline
(command "leader")
(foreach Pt PtList
(command Pt);feed points to leader
)
(command "" "_Annotation" "" "_N");;finish leader cmd
(princ)
)
RE: Leader Lisp
Thanks.
RE: Leader Lisp
CODE
(setvar "CMDECHO" 0);disable command prompts
(setq Pt1 (getpoint "\nSelect leader start point: "))
(setq PtList (list Pt1));list of 1 point
(command "pline" Pt1);;start pline command with first point
(while (setq Pt1 (getpoint Pt1 "\nNext point: "))
(command Pt1);;draw next point of polyline)
(setq ptList (cons Pt1 PtList));;add point to list
)
(command "");end pline command
(setq ptList (reverse PtList));reverse so first point at front
(entdel (entlast));delete pline
(command "leader")
(foreach Pt PtList
(command Pt);feed points to leader
)
(command "_Annotation" "" "_N");;finish leader cmd
(princ)
)
RE: Leader Lisp