newer 发表于 2021-1-7 17:39:37

使用 (princ "\r") 不能更新命令行的问题

问题:
I've been using (princ "\r") to update the command line inside my LISP command, but in AutoCAD 2011 it does not seem to work anymore.

You can use the following code to reproduce the issue:


(defun pause(mili / time)
(setq time (getvar "date"))
(while (< (* (- (getvar "date") time) 100000000) mili))
nil
)

(defun c:printtest ()
(princ "\n")
(setq num 1)
(repeat 100
    (pause 100)
    (setq num (1+ num))
    (princ "\r")
    (princ num)
)
)


As you can see in AutoCAD 2011 only the last number (101) appears in the command line once the command finished, but nothing in between. This used to work fine before.

解答:
This behaviour has been logged. The workround is to use an additional (princ):


(defun pause(mili / time)
(setq time (getvar "date"))
(while (< (* (- (getvar "date") time) 100000000) mili))
nil
)

(defun c:printtest ()
(princ "\n")
(setq num 1)
(repeat 100
    (pause 100)
    (setq num (1+ num))
    (princ "\r")
    (princ num)
    (princ) ; with the addition of this the command line gets updated
)
)


页: [1]
查看完整版本: 使用 (princ "\r") 不能更新命令行的问题