AutoLISP虚拟线变化图
2011-03-29 22:31 精诚所至 金石为开 阅读(469) 评论(0) 编辑 收藏 举报AutoLISP虚拟线变化图,代码如下。
(defun c:test()
(setvar "cmdecho" 0)
(setq k 1 n 1 hh 1)
(get_screen_size)
(while k
(grread k)
(while (>= hh 0.0005)
(setq cc (rem n 7))
(if (= cc 0) (setq cc 7))
(draw_screen)
)
(setq n (1+ n) hh 1)
(setq p1 p1_old p2 p2_old p3 p3_old p4 p4_old)
)
)
(defun get_screen_size()
(setq cp (trans (getvar "viewctr") 1 2))
(setq pt1 (trans (getvar "vsmin") 1 2))
(setq pt2 (trans (getvar "vsmax")1 2))
(setq xscl (- (car pt2) (car pt1)))
(setq yscl (- (car pt2) (cadr pt1)))
(setq sh (getvar "viewsize"))
(setq sw (* sh (/ xscl yscl)))
(setq p1_old (list (- (car cp) (* 0.5 sw)) (- (cadr cp) (* o.5 sh))))
(setq p3_old (list (+ (car cp) (* 0.5 sw)) (+ (cadr cp) (* o.5 sh))))
(setq p2_old (list (car p3_old) (cadr p1_old)))
(setq p4_old (list (car p1_old) (cadr p3_old)))
(setq p1 p1_old p2 p2_old p3 p3_old p4 p4_old)
)
(defun draw_screen()
(setq hh (/ sh 30))
(setq an1 (angle p1 p2))
(setq an2 (angle p2 p3))
(setq an3 (angle p3 p4))
(setq an4 (angle p4 p1))
(setq p1 (polar p1 an1 hh))
(setq p2 (polar p2 an2 hh))
(setq p3 (polar p3 an3 hh))
(setq p4 (polar p4 an4 hh))
(grdraw p1 p2 cc)
(grdraw p2 p3 cc)
(grdraw p3 p4 cc)
(grdraw p4 p1 cc)
(setq sh (distance p1 p4))
)
(princ "\n------<<TEST>>------")
(prin1)
代码完。