So I've got a bit of lisp that I just threw together. The goal is to create three plines and a single line with at half inch space between the lines. I also only want it to work when the line being drawn is perfectly vertical or horizontal.
This bit of code seems to work about 1/2 the time. It blows up when you try to draw a really long line or if you draw a vertical segment and then osnap a horizontal segment to it.
Thanks,
-Brandon
(defun C:lll()
;;;--- command echo off
(setvar "cmdecho" 0)
(setq pt1(getpoint "\n Start Point: "))
(setq pt2(getpoint pt1"\n Second Point: "))
(setq x1(car pt1))
(setq x2(car pt2))
(setq y1(cadr pt1))
(setq y2(cadr pt2))
(COMMAND "_PLINE" pt1 pt2 "")
(cond ((= x1 x2)
(setq bxpt1(+ x1 0.5))
(setq bxpt2(+ x2 0.5))
(setq bxline1(list bxpt1 y1 0))
(setq bxline2(list bxpt2 y2 0))
(COMMAND "_PLINE" bxline1 bxline2 "")
(setq cxpt1(+ x1 1))
(setq cxpt2(+ x2 1))
(setq cxline1(list cxpt1 y1 0))
(setq cxline2(list cxpt2 y2 0))
(COMMAND "_PLINE" cxline1 cxline2 "")
(setq gxpt1(+ x1 1.5))
(setq gxpt2(+ x2 1.5))
(setq gxline1(list gxpt1 y1 0))
(setq gxline2(list gxpt2 y2 0))
(COMMAND "_LINE" gxline1 gxline2 "")
);_ end of the first then condition
((= y1 y2)
(setq bypt1(- y1 0.5))
(setq bypt2(- y2 0.5))
(setq byline1(list x1 bypt1 0))
(setq byline2(list x2 bypt2 0))
(COMMAND "_PLINE" byline1 byline2 "")
(setq cypt1(- y1 1))
(setq cypt2(- y2 1))
(setq cyline1(list x1 cypt1 0))
(setq cyline2(list x2 cypt2 0))
(COMMAND "_PLINE" cyline1 cyline2 "")
(setq gypt1(- y1 1.5))
(setq gypt2(- y2 1.5))
(setq gyline1(list x1 gypt1 0))
(setq gyline2(list x2 gypt2 0))
(COMMAND "_LINE" gyline1 gyline2 "")
);_ end of the second then condition
(t
(princ "\nDraw a straight line.<<<------------------------------------------")
) ;_ end of optional else condition
) ;_ end of cond statement
;;;--- command echo back on
(setvar "cmdecho" 1)
(princ)
)


Reply With Quote

