Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Leader Lisp 1

Status
Not open for further replies.

Volk359

Technical User
Jun 30, 2004
395
US
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:
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")
)

and here's the WHILE code from the old lisp:

Code:
(while (setq pt2 (getpoint pt2 "\n   To point: "))
   (command pt2)) (command "")

If that code is used in the leader command it errors and starts a regular leader entity.

Thanks,

Keith
 
I don't see a way of incorporating the unlimited picks in the command & displaying it as you go. Could use the "pline" command, erase it, use points in the "leader" command.

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)
)
 
That works real well, exactly what I'm looking for but you're right it doesn't display it. I can imagine the frantic phone calls if I use it, though.

My lisp is a bit rusty, how could we incorporate your idea of using a pline?
 
Hmmm..shooting from the hip. No error trapping-

(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)
)
 
Wow, pretty slick! BTW, had to remove the first set of double quotes in the last command line. Unfortunately the rubber band doesn't show, is there a chance of turning it on? I hate to be picky but with these guys here ANY change would be devastating.

Thanks.
 
Ok, just one change to the "getpoint" line. You're welcome :)

Code:
(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 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)
)
 
Par excellent! Thanks very much for your time and efforts!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top