AutoLISP 計時器(Timer)
基本上方法是使用時間相減得到時間差,而得到計時功能。
因為在AutoCAD版本上的改變,所以程式上會有所不同,主因是因為從2017開始date系統變數不再儲存到當前毫秒,在2016以前是使用date系統變數,而在2018之後則是使用millisecs系統變數(此系統變數是從2018才加入)。
下面是使用於版本2016以前
因為在AutoCAD版本上的改變,所以程式上會有所不同,主因是因為從2017開始date系統變數不再儲存到當前毫秒,在2016以前是使用date系統變數,而在2018之後則是使用millisecs系統變數(此系統變數是從2018才加入)。
下面是使用於版本2016以前
(defun C:Timer2016 (/ begin)
(defun gettime (/ s seconds)
(setq s (getvar "DATE"))
(setq seconds (* 86400.0 (- s (fix s))))
)
(setq begin (gettime))
; 加入500毫秒間隔
(command "._delay" 500)
(setvar "dimzin" 8)
(princ (strcat "\n" (rtos (- (gettime) begin) 2 12)))
(princ)
)
下面是使用於版本2018以後(defun c:Timer2018 (/ s e)
(setq s (getvar "millisecs"))
; 加入500毫秒間隔
(command "._delay" 500)
(setvar "dimzin" 8)
(setq e (getvar "millisecs"))
(princ (strcat "\n" (rtos (/ (- e s) 1000.0) 2 12)))
(princ)
)
留言
張貼留言