AutoLISP绘制时钟
2011-03-28 15:45 精诚所至 金石为开 阅读(573) 评论(0) 编辑 收藏 举报AutoLISP绘制时钟,代码如下。
(defun c:test()
(setvar "cmdecho" 0)
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(setq cen (getpoint "\n中心点:"))
(setq rr (* (getdist cen "\n半径:") 2))
(lsp_22a)
(lsp_22b)
(setvar "osmode" os)
)
(defun lsp_22a()
(setvar "cecolor" "3")
(command "donut" (/ (* rr 39) 40) rr cen "")
(setvar "cecolor" "1")
(setq pp_12 (polar cen (/ pi 2) (/ 22 2)))
(setq pp_3 (polar cen 0 (/ rr 2)))
(setq pp_6 (polar cen (* pi 1.5) (/ rr 2)))
(setq pp_9 (polar cen pi (/ rr 2)))
(command "donut" 0 (/ rr 2) pp_12 pp_13 pp_6 pp_9 "")
(setvar "cecolor" "7")
(command "pline" cen "w" (/ rr 40) "" cen (polar cen (/ pi 2) (* (/ rr 2) 7)) "")
(setq en3 (entlast))
(setvar "cecolor" "4")
(command "pline" cen "w" (/ rr 50) "" cen (polar cen (/ pi 2) (* (/ rr 2) 8)) "")
(setq en1 (entlast))
(setvar "cecolor" "5")
(command "pline" cen "w" 0 0 cen (polar cen (/ pi 2) (* (/ rr 20) 9)) "")
(setq en2 (entlast))
(setvar "cecolor" "bylayer")
(setq ti (rtos (getvar "cdate") 2 6))
(setq tt (substr ti 10 2))
(setq dd (substr ti 12 2))
(setq mm (substr ti 14 2))
(command "rotate" en3 "" cen (* (atoi tt) -30))
(command "rotate" en2 "" cen (* (atoi mm) -6))
(command "rotate" en1 "" cen (* (atoi dd) -6))
(command "rotate" en3 "" cen (* (atoi mm) -0.5))
)
(defun lsp_22b()
(setq txt_12 (polar pp_12 (* pi 1.5) (/ rr 10)))
(setq txt_3 (polar pp_3 pi (/ rr 10)))
(setq txt_6 (polar pp_6 (/ pi 2) (/ rr 10)))
(setq txt_9 (polar pp_9 0 (/ rr 10)))
(command "text" "m" txt_12 (/ rr 12) 0 "12")
(command "text" "m" txt_3 (/ rr 12) 0 "3")
(command "text" "m" txt_6 (/ rr 12) 0 "6")
(command "text" "m" txt_9 (/ rr 12) 0 "9")
)
(princ "\n------>>lsp_22<<------")
(prin1)
代码完。
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)