AutoCADLISP绘制楼梯

AutoCAD LISP绘制楼梯,控制方向和阶数高度等,代码如下。

(defun c:test()
  (setvar "cmdecho" 0)
  (setq nn (getint "\n阶数<5>:"))
  (if (null nn) (setq nn 5))
  (setq pt1 (getpoint "\n第一点:"))
  (setq pt2 (getpoint "\n第二点:"))
  (setq ww (distance pt1 pt2))
  (setq str_hh (strcat "\n高度<" (rtos ww 2) ">:"))
  (setq hh (getdist pt1 str_hh))
  (if (null hh) (setq hh ww))
  (setq ang (angle pt1 pt2))
  (setq ptbas pt2)
  (command "pline" pt1 ptbas)
  (repeat nn
    (setq ptbas (polar ptbas (+ ang (/ pi 2)) (/ hh nn)))
    (command ptbas)
    (setq ptbas (polar ptbas (+ ang pi) (/ ww nn)))
    (command ptbas)
    )
  (command "c")
  (prin1)
  )

代码完。

作者:codee
文章千古事,得失寸心知。


原文地址:https://www.cnblogs.com/bimgoo/p/2502961.html