Automatically save files

Automatically save files

marcos.olivetti
Contributor Contributor
1,032 Views
18 Replies
Message 1 of 19

Automatically save files

marcos.olivetti
Contributor
Contributor

Hi guys how are you? Could you explain if there is a LISP, or similar file, that automatically saves a DWG file at an established time? For example, I'm working on my project and I would like the sheet (model) I work on to be automatically saved (QS) every 5 minutes, without the need for me to manually save it? Could this be done?

Olivetti - Brazil

1,033 Views
18 Replies
Replies (18)
Message 2 of 19

komondormrex
Mentor
Mentor

why do not you using the autosave option?

komondormrex_0-1686764413431.png

 

Message 3 of 19

3de_projetos
Participant
Participant

It never works well for me, every time I need to recover it gives an error, the file does not come to the point before the last save, in my opinion it does not work well.

0 Likes
Message 4 of 19

pendean
Community Legend
Community Legend

@3de_projetos @marcos.olivetti A quick overview of what AutoSAVE does and does not do https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Understanding-Auto...

 


@3de_projetos wrote:

...every time I need to recover it gives an error...


Are you stating that your AutoCAD crashes that often that recovering files is a regular need?

 

 

Message 5 of 19

3de_projetos
Participant
Participant

Not as often, but when it does, the loss of work is considerable.

0 Likes
Message 6 of 19

Kent1Cooper
Consultant
Consultant

The way we used to do this was to redefine something we used relatively frequently, such as REDRAW, to include a check on the time since the last saving command, by comparing the value in the DATE System Variable to that in TDUPDATE.  If that's more than a certain amount, do QSAVE.  I expect a lot of people don't use REDRAW so much any more, probably because most people don't work with blips turned on [I do, because they provide real and worthwhile information], so that may not be the best command to use for the purpose, but it could be done with some other command, preferably not a drafting one like Line but something display-related like Zoom?

EDIT:

Like this, included at the front of whatever command you make a new definition of:

 

(if (> (rem (- (getvar 'date) (getvar 'tdupdate)) 1.0) 0.00347222)

  (command "_.qsave")

); if

 

[Those System Variables report in decimal days, and 5 minutes is one 288th or .00347222... of a day.  Adjust for other intervals.]

 

It should be a non-transparent-capable command [so not Zoom after all] that is redefined to include such a thing, because QSAVE itself cannot be invoked transparently.  I think maybe we used to have it set up so that it didn't just QSAVE, but asked whether you wanted to do so.  But I don't use that any more -- I just save [like voting] "early and often."

 

In any case, it needs to be tied to doing something, that is, triggered by something, because I don't think there's anything in AutoCAD that is constantly monitoring the passage of time, that could make it happen regularly on its own.  And besides, when you step away from your computer for a while, would you really want the drawings you have open QSAVEd over and over when nothing has happened in them?

Kent Cooper, AIA
Message 7 of 19

pendean
Community Legend
Community Legend

@3de_projetos wrote:

Not as often, but when it does, the loss of work is considerable.


We've luckily never gotten so bad behind in 30+years now, wonder why it can be so for you.

 

I would do what @Kent1Cooper suggested: build QSAVE solutions into actions, commands, and function you use often: I myself have shortcut to a LISP that creates a save-to-another-folder and QSAVE at the same time, many others in my office prefer to create LISP shortcuts that "QSAVE" before launching tools they use often like PLOT, ATTACH, PDFIMPORT, OPEN, LAYER, XREF and much more.

Message 8 of 19

3de_projetos
Participant
Participant
I really appreciate everyone's help, I'll do it like this, thank you
0 Likes
Message 9 of 19

3de_projetos
Participant
Participant

I really appreciate everyone's help, I'll do it like this, thank you

0 Likes
Message 10 of 19

Kent1Cooper
Consultant
Consultant

[@3de_projetos and @marcos.olivetti , are you the same person?  @3de_projetos is replying in terms that sound like they're the Original Poster, but they're not.  And what is "like this" in Message 9?]

Kent Cooper, AIA
Message 11 of 19

3de_projetos
Participant
Participant

I don't know anything about lisp sorry, the basics, the basics. How would a function, a command look like, so that when I trigger the TRIM command, for example, it saves the file? Could you help me with this?

0 Likes
Message 12 of 19

Sea-Haven
Mentor
Mentor

If you have Autosave set it will make temporary files that can be found, these can be helpful in a crash. 

 

You can also look at where your autosave files are located, Options, Files.

 

They will have a name like SV$ can be renamed to dwg and opened.

 

So many people dont know about this directory and it can have Gigbytes of data in it, I clean mine out all the time.

Message 13 of 19

pendean
Community Legend
Community Legend

@3de_projetos wrote:

...so that when I trigger the TRIM command, for example....


How exactly do your "trigger" TRIM command most often?

0 Likes
Message 14 of 19

3de_projetos
Participant
Participant

command TR

0 Likes
Message 15 of 19

pendean
Community Legend
Community Legend

@3de_projetos wrote:

command TR


quick and dirty method...

(defun c:TR () (command "qsave" "trim"))

 

Worth a deep dive when you have time to refine your needs https://www.afralisp.net/autolisp/tutorials/the-basics-part-1.php

0 Likes
Message 16 of 19

Kent1Cooper
Consultant
Consultant

@3de_projetos wrote:

.... How would a function, a command look like, so that when I trigger the TRIM command, for example, it saves the file? ....


This is the less-quick-and-less-dirty approach I had in mind:

 

(command "_.undefine" "TRIM")
(defun C:TRIM ()
  (if (> (rem (- (getvar 'date) (getvar 'tdupdate)) 1.0) 0.00347222)
    (command "_.qsave")
  ); if
  (command "_.trim")
  (prin1)
)

 

What's "less quick-and-dirty" about it than @pendean's TR suggestion?

1.  His requires you to enter the command name in just that way with TR only [it won't do it if you type the whole word TRIM, or pick the Trim icon in the ribbon], but mine operates with the whole command name or the alias [even if you change the alias for Trim] or the ribbon icon.

2.  His does the QSAVE every time you use the TR command name, regardless, but mine QSAVEs only when it has been longer than 5 minutes since the last saving operation.

 

Put that into a file with a .lsp filetype ending, and APPLOAD that to do the undefining and new definition.  You can have it loaded automatically in every drawing with acaddoc.lsp, if you like.

 

Change the long decimal number for a different time limit [it's for 5 minutes, as a decimal portion of a day].  It would be possible to have it ask you for the time limit, but you probably don't want to answer that question every time you want to Trim, so maybe at only the first use in a drawing session?

 

You can still use the regular TRIM command without the save-time check, by preceding the command name or alias with a period -- .TR or .TRIM.

Kent Cooper, AIA
0 Likes
Message 17 of 19

Vuxvix
Advocate
Advocate

I using this App: comSaveIt! 
I almost didn't notice the auto save process when using this app. It will also save a backup file to a folder you specify. Whether when shutting down the file you save it or not.
Combined with how much Autosave time setting. It will save you many files.

Message 18 of 19

3de_projetos
Participant
Participant

THANK YOU SO MUCH PERFECT

0 Likes
Message 19 of 19

3de_projetos
Participant
Participant

THANK YOU VERY MUCH, EXCELLENT TIP!

0 Likes