见图示,直接绘制一条线即可自动生成由圆堆叠成的金字塔。
- ;;;*****************金字塔 程序开始*************
- (defun c:jzt ()
- (setvar "osmode" 15359)
- (setvar "cmdecho" 0)
- (command "undo" "be")
- (princ "\n★功能:绘制金字塔.\n")
- (initget 1)
- (setq pt1 (getpoint "\n起点:"))
- (initget 1)
- (setq pt2 (getpoint pt1 "\n终点:"))
- (setq nn (getint "\n层叠数<10>:"))
- (if (null nn)
- (setq nn 10)
- )
- (setq dd (distance pt1 pt2))
- (setq ang (angle pt1 pt2))
- (setq rr (/ (/ dd (1- nn)) 2))
- (setq nn2 nn)
- (setvar "osmode" 0)
- (repeat nn
- (setq bas pt1)
- (repeat nn2
- (command "circle" bas rr)
- (setq bas (polar bas ang (* rr 2)))
- )
- (setq nn2 (1- nn2))
- (setq pt1 (polar pt1 (+ ang (/ (* 60 PI) 180)) (* rr 2)))
- )
- (command "undo" "e")(setvar "osmode" 15359)(princ))
- ;;;想看隐藏部分请回复。。。
;;;*****************金字塔 程序结束*************
|