I have the following line in my acaddoc.lsp:
(SETVAR "MODEMACRO"
"$(Getvar,LOGINNAME) last saved $((* 1440 (substr,$(getvar,date), $(getvar,tdupdate)))) mins ago")
You can probably see what I'm trying to do.
The LOGINNAME part works fine, but the time doesn't. The goal is to constantly display the elapsed time since the last save, formatted in minutes. The function is not working; here's what I get in my status bar:
I'm a novice at lisp and diesel, but I thought I could get this one.
I also tried this way:
Command: (setq mydate (getvar "date"))
2.45664e+006
Command: (setq savedate (getvar "tdupdate"))
2.45664e+006
Command: (setq minsincesave (* 1440 (- mydate savedate)))
34.7048
This actually worked, in a way. I could call the setq "minsincesave" in a mtext field "LispVariable", and I probably could put in in a modemacro too (didn't try). But the problem here is that "mydate" and "savedate" (and "minsincesave") are not automatically updated. I had mtext with the field displaying "minsincesave", and it won't update unless you run all the (setq ....) again for each variable. I guess I understand: the setq is set, and it doesn't change even if the variable does change.
Thanks for any suggestions.
Mark Green
Working on Civil 3D in Canada
Solved! Go to Solution.
Solved by troma. Go to Solution.
Solved by Lee_Mac. Go to Solution.
If I'm not mistaken, this would require a reactor to keep the modemacro updated; but beware, the mode status line is used often to display useful data. Overriding it could prove unpredictable. In cases when I need to update the value, I strcat the natural value with my value.
Try this:
(setvar 'modemacro "$(getvar,loginname) last saved $(edtime,$(-,$(getvar,date),$(getvar,tdupdate)),HH:MM:SS) ago")
@mid-awe wrote:If I'm not mistaken, this would require a reactor to keep the modemacro updated; but beware, the mode status line is used often to display useful data. Overriding it could prove unpredictable. In cases when I need to update the value, I strcat the natural value with my value.
No reactor should be required as the DIESEL expression should be updated automatically (similar to RTEXT behaviour), however, the value won't be updated in real-time second-by-second, but rather as the user issues commands / pans / zooms - essentially any operation in AutoCAD should update the value.
Can you tell me why you use (setvar 'modemacro instead of (setvar "modemacro" ?
Anyway, it worked. But a couple of issues: when you open a drawing, it displays the time since it was previously saved, but the days are omitted. So you might think it was saved 15 mins ago, when it was actually 48 hours and 15 mins. Also, in that case, it is misleading to say that the current LOGINNAME saved it, since it was likely saved by someone else.
So I modified your code, to this:
(setvar 'modemacro "$(getvar,loginname) | Saved $(fix, $(*, 1440 [,$(-,$(getvar,date),$(getvar,tdupdate))])) mins ago")
Wow did it ever take me a long time to figure out multiplication and rounding! I kept putting in too many brackets.
Thanks!
Mark Green
Working on Civil 3D in Canada
Mark Green
Working on Civil 3D in Canada
@troma wrote:
Can you tell me why you use (setvar 'modemacro instead of (setvar "modemacro"?
Personal preference - both are equivalent as the getvar/setvar functions accept either a symbol or string argument. The symbol requires fewer keystrokes.
@troma wrote:
Anyway, it worked. But a couple of issues: when you open a drawing, it displays the time since it was previously saved, but the days are omitted. So you might think it was saved 15 mins ago, when it was actually 48 hours and 15 mins. Also, in that case, it is misleading to say that the current LOGINNAME saved it, since it was likely saved by someone else.
I was simply following the format of your original example...
Glad you got it working how you want it
@mid-awe wrote:I suppose I was not thinking about the "built in" reactor-like behavior of DIESEL expressions.
You are the man Lee 🙂
No worries mate - cheers!