Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MODEMACRO "saved xx mins ago"

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
troma
878 Views, 7 Replies

MODEMACRO "saved xx mins ago"

 

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:  Modemacro not working.PNG

 

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

7 REPLIES 7
Message 2 of 8
mid-awe
in reply to: troma

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.

Message 3 of 8
Lee_Mac
in reply to: troma

Try this:

 

(setvar 'modemacro "$(getvar,loginname) last saved $(edtime,$(-,$(getvar,date),$(getvar,tdupdate)),HH:MM:SS) ago")

 

Message 4 of 8
Lee_Mac
in reply to: mid-awe


@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.

Message 5 of 8
troma
in reply to: Lee_Mac

 

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

Message 6 of 8
mid-awe
in reply to: Lee_Mac

I suppose I was not thinking about the "built in" reactor-like behavior of DIESEL expressions.

You are the man Lee 🙂
Message 7 of 8
troma
in reply to: mid-awe

If you just leave it sitting and don't touch it, it won't update.

But all you have to do is click on the screen or hit the Esc button, and the time updates.
Pretty sweet!

Mark Green

Working on Civil 3D in Canada

Message 8 of 8
Lee_Mac
in reply to: troma


@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 Smiley Happy

 


@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! Smiley Happy

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost