View Full Version : LISP Challenge - draw a specialized leader
fletch97
2006-02-27, 05:33 PM
Morning -
Trying to write a lisp routine to allow a user to draw a specialized leader but I am unsure of how to do this one. (See the attached dwg.) Normally, I could create a block of the end and add it to the leader properties but in this case I need to allow the user to designate the length of the selection box. As you can see from the dwg....the selection can vary depending on the amount of wires shown. I was thinking that it would start off by prompting you like a normal leader, where you pick your first point, second, third....but not text option and than the fourth option would be the length of the selection box. I am really unsure of how to approach this one....right now we just insert them in from a blocks library and than have to stretch and move it accordingly. Any help would really be appreciated!!
Thanks!!
boesiii
2006-02-27, 06:16 PM
Fletch,
The attached files should help.
The lisp file creates a few text styles and dim styles based on the scale factor input by the user. Look at the "elec leader" dim style after you run the command.
To expand the size of the leader, change the size in the properties box.
H'Angus
2006-02-27, 06:17 PM
My first thoughts would be to add a dynamic block to the leader and have the fourth option to indicate the length of the DB.
fletch97
2006-02-27, 06:38 PM
Boesii -
I am unsure why the drawing has the arc'd loop? I need the rectangular loop as shown in my attached drawing. I've actually already created the arc'd loop and got that working based off the dimscale. But this rectangular loop needs to be based off the user input.
Thanks!
fletch97
2006-02-28, 05:56 PM
OK....I got some help from another forum on this challenge.
Check out the lisp below...
(defun c:boxleader ()
(setq p1 (getpoint "nPick on one side of cable bundle: ")
p2 (getpoint p1 "nPick on the other side of cable bundle: ")
distancebetween (- (cadr p2) (cadr p1))
p2 (list (car p1) (+ distancebetween (cadr p1)))
width (abs (* distancebetween 0.2))
p3 (mapcar '+ p2 (list width 0.0))
p4 (mapcar '+ p1 (list width 0.0))
p5 (mapcar '- p4 (list (* 2.0 width) 0.0))
)
(setvar "orthomode" 1)
(command "pline" p1 p2 p3 p4 p5 p1)
)This lisp works well going vertically with the leader but doesn't work going horizontally? I'd also like the width of the boxed leader to remain at 4" regardless of how long the leader becomes. Any ideas or suggestions are greatly appreciated!
[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]
Try this one:
(defun c:boxleader (/ DISTANCEBETWEEN P1 P2 P3 P4 P5 WIDTH)
(setvar "orthomode" 1)
(setvar "osmode" 0)
(setq p1 (getpoint "nPick on one side of cable bundle: ")
p2 (getpoint p1 "nPick on the other side of cable bundle: "))
(if (or (equal (angle p1 p2) 0 0.001)
(equal (angle p1 p2) pi 0.001))
(progn
(setq distancebetween (abs (- (car p2) (car p1)))
width (abs (* distancebetween 0.2))
p2 (list (car p1) (+ (cadr p1) width) 0.0)
p3 (list (+ (car p1) distancebetween)(cadr p2) 0.0)
p4 (list (car p3) (+ (cadr p3) width) 0.0)
p5 (list (car p1) (+ (cadr p1) (* 2 width)) 0.0)
)
(command "pline")
(mapcar 'command (list p1 p2 p3 p4 p5 p2 p1))
(command "")
)
(progn
(setq distancebetween (abs (- (cadr p2) (cadr p1)))
width (abs (* distancebetween 0.2))
p2 (list (+ (car p1) width) (cadr p1) 0.0)
p3 (list (+ (car p2) width )(cadr p2) 0.0)
p4 (list (car p3) (+ (cadr p3) distancebetween) 0.0)
p5 (list (- (car p4) width) (cadr p4) 0.0)
)
(command "pline")
(mapcar 'command (list p1 p3 p4 p5 p2 p1))
(command "")
)
)
(setvar "osmode" 703)
)
f.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.