我第一次用lisp写了一个画楼梯踏步的程序,就是实现以下:功能输入楼梯踏步宽,步数,以及高度就可以把那条折线画出来,写完了加载后应用起来有问题,有时能成功,有时不行,请高手帮忙看一下怎么回事?程序代码如下:
;LTTB.LSP ;楼梯踏步
(defun c:lttb (/ oce p1 p3 a1 a2 p2 x1 x2 y1 s1 h1 h2 n1) (graphscr) (setq oce (getvar "cmdecho") ) (setvar "cmdecho" 0)
(setq p1 (getpoint "\nThe start point of The stair: ") n1 (getint "\nThe number of The stair: ") s1 (getint "\nThe width of The stair: ") h1 (getint "\nThe total-heigth of the stair: ") n1 (+ n1 1) h2 (/ h1 n1 1.0) h2 (* h2 2.0) s1 (* s1 2) x2 (car p1) ) (while (< (car p1) (+ x2 (* n1 s1) ) ) (setq x1 (car p1) y1 (cadr p1) p2 (list x1 (+ y1 h2) ) p3 (list (+ x1 s1) (cadr p2) ) ) (command ".pline" p1 "w" 0 "" p2 p3 "") (setq p1 p3) ) (setq x1 (car p1) y1 (cadr p1) p1 (list (- x1 (* n1 s1 ) ) (- y1 (* h1 2.0) ) ) a1 (entlast) a2 (ssget "w" p1 p3) )
(command ".pedit" a1 "j" a2 "" "" )
(setvar "cmdecho" oce) (princ)
) |