Author Topic: Saving at regular intervals  (Read 10708 times)

0 Members and 1 Guest are viewing this topic.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15500
Saving at regular intervals
« on: April 12, 2005, 09:21:26 AM »
I am looking for advice.

I am hoping to be able to write a lisp which performs a qsave every 5 or 10 minutes. Can anyone give me any ideas on where to start, and if there is a function in lisp that calculates time.

Be prepared for "dumb" questions, as I am trying to write my first proper lisp command. :?

Many thanks an advance
Thanks for explaining the word "many" to me, it means a lot.

Water Bear

  • Guest
saving
« Reply #1 on: April 12, 2005, 09:29:35 AM »
Why don't u just turn on the autosave feature tools=>options=>open/save
and you can set time interval, extension ets...

jonesy

  • SuperMod
  • Seagull
  • Posts: 15500
Saving at regular intervals
« Reply #2 on: April 12, 2005, 09:47:51 AM »
Does autosave do a full save to dwg format?
I was always under the impression that autosave was an emergency only option, and should only be re-named and used in the direst of circumstances.
Thanks for explaining the word "many" to me, it means a lot.

hudster

  • Gator
  • Posts: 2846
Saving at regular intervals
« Reply #3 on: April 12, 2005, 09:58:10 AM »
Here is a lisp to autosave your drawings, this does an actual save.

Be aware it will save over your drawings so if you don't want to save changes you need to undo everything prior to closing a drawing.

I stopped using it after I overwrote an architects drawings and had to beg him for another copy.

Code: [Select]
; =========================================================
;   AUTOSAVE.LSP             By:   Jeff Pilcher
;
;   This is an AutoLISP routine for use with the
;   AutoCAD drafting software.
;
;   I am providing this routine to other users of
;   AutoCAD under the SHAREWARE concept. I would
;   like to recover some of the cost of my time
;   spent developing this and other AutoLISP
;   routines for AutoCAD, by asking for voluntary
;   payments.
;
;   If you find this routine is useful to you in
;   doing paying work, please send $5 to:
;
;              Jeffrey S. Pilcher
;
;              Production Systems
;              P.O. Box 218
;              Richmond, IL  60071
;
;              (815) 678-4562
;
;   Obviously $5 is not going to make me rich, or break
;   your bank account.  It will however, show me that
;   someone out there appreciates my efforts, and give
;   me the incentive to write more useful routines.
;
;   I would be very interested in seeing any routines
;   written by you or anyone else. In other words, an
;   exchange of routines would make me as happy as a
;   $5 payment, (well, almost as happy).
;
;   Feel free to pass this routine on to other AutoCAD
;   users, but PLEASE, do not remove these comments.
;
;   Good luck, have fun, and LONG LIVE AutoDESK !!!
;
; =========================================================
;
;
;   This is a routine to automatically save your drawing at
;   regular intervals during the editing session.
;
;   There are a lot of autosave routines out there, but I think
;   this is the most straight forward of the bunch.
;
;   AUTOSAVE.LSP main features:
;
;          1) Can be turned on or off as you see fit.
;
;          2) You specify how often you want to AUTOSAVE.
;
;          3) When it is not time to AUTOSAVE, it tells
;             you how much time is left so you know exactly
;             what is happenning.
;
;          4) When it is AUTOSAVING, it tells you the name
;             of the drawing being AUTOSAVED.
;
;   INSTALLATION:
;
;     To utilize this routine you should include the code portion
;     in your ACAD.LSP file.
;
;     After you have installed AUTOSAVE.LSP in your ACAD.LSP file
;     you will need to include the command "(c:setauto)" as the
;     last statement in your ACAD.LSP file.  This will cause
;     AutoCAD to prompt the user with the message:
;
;         Do you want to do AUTOSAVES ?
;
;     upon entering the drawing editor.
;
;     Then include the command AUTOSAVE  under many of the menu
;     picks in your tablet menu.
;
;
;   OPERATION:
;
;     When you enter the drawing editor, and as the ACAD.LSP
;     file is being loaded, the operator will be asked if he/she
;     would like to do AUTOSAVES:
;
;          Do you want to do AUTOSAVES ?
;
;     A response of [ y ] or [ Y ] will turn AUTOSAVE on, AutoCAD
;     will tell the operator that AUTOSAVE is on with the prompt:
;
;          AUTOSAVE is on.
;
;     Any other response will turn AUTOSAVE off, AutoCAD will
;     tell the operator that AUTOSAVE is off with the prompt:
;
;          AUTOSAVE is off.
;
;     If the operator has chosen to do AUTOSAVES by responding
;     [ y ] or [ Y ] he/she will be asked how often to AUTOSAVE
;     with the prompt:
;
;          How often would you like to AUTOSAVE, in minutes <15>:
;
;     The operator should at this time enter a number indicating
;     how often they would like AutoCAD to AUTOSAVE thier drawing.
;     The default is 15 minutes. If 15 minutes is acceptable,
;     simply hit <ENTER>.
;
;     Upon picking one of the tablet picks which contains the
;     AUTOSAVE command, AutoCAD will check to see how long it has
;     been since it last AUTOSAVED your drawing.  If the time
;     since the last AUTOSAVE has exceeded the desired interval,
;     AutoCAD will automatically save your drawing for you, and
;     tell you what is happenning with the prompt:
;
;          AUTOSAVING:  <dwgname>
;          Please stand by ....
;
;     (never again will you loose 4 hours of work due to a systems
;     crash or power failure).
;
;     If the time since the last AUTOSAVE has not exceeded the
;     desired interval, AutoCAD will tell you with the prompt:
;
;          Not time yet .... xx.x minutes left.
;
;     As you can see, it will tell how much time is left until the
;     next AUTOSAVE.
;
;
;   EXTRA FEATURES:
;
;     The AUTOSAVE routine can be turned on or off at any time you
;     desire while in the drawing editor by typing [ SETAUTO ], at
;     the command prompt, and answering the prompt:
;
;          Do you want to do AUTOSAVES ?
;
;     with the proper response. This prompt is the same prompt you
;     get when you first enter the drawing editor. Therefore you
;     will also be asked to enter a time interval for the AUTOSAVE
;     program. So not only can you turn AUTOSAVVES on or off, but,
;     you can also change the time interval whenever you like.
;
;

(defun setauto ()
  (setq answer (strcase (getstring "\nDo you want to do AUTOSAVES ?  ")))
  (if (> (strlen answer) 1)
    (setq answer (substr answer 1 1))
  )
  (if (= answer "Y")
    (progn
      (prompt "\nAUTOSAVE is on.")
      (print)
      (setq minutes (getreal "\nHow often would you like to AUTOSAVE, in minutes <15>: "))
      (if (= minutes nil)
        (setq minutes 15.0)
      )
    )
    (prompt "\nAUTOSAVE is off.")
  )
  (print)
)
(defun C:autosave ()
  (if (= answer "Y")
    (saveit)
    (prompt "\nAUTOSAVE is turned off !")
  )
  (print)
)
(defun saveit ()
  (if (= D1 nil)
    (setq D1 (getvar "DATE"))
  )
  (if (> (* (- (getvar "DATE") D1) 1440.0) minutes)
    (progn
      (setvar "cmdecho" 0)
      (prompt (strcat "\nAUTOSAVING:  " (getvar "dwgname")))
      (prompt "\nPlease stand by .... ")
      (print)
      (command "SAVE" "")
      (prompt "\nAUTOSAVE complete.")
      (prompt "\nThank you for waiting.")
      (setq D1 (getvar "DATE"))
      (setvar "cmdecho" 1)
    )
    (progn
      (prompt "\nNot time yet .... ")
      (princ (rtos (- minutes (* (- (getvar "DATE") D1) 1440.0)) 2 1))
      (princ " minutes left.")
    )
  )
  (print)
)
;
(setauto)
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Jeff_M

  • King Gator
  • Posts: 3942
  • C3D user & customizer
Saving at regular intervals
« Reply #4 on: April 12, 2005, 01:17:16 PM »
I use a VBA solution that saves after so many commands (excluding zoom & undo) have been run. If you are interested in that approach I'd be willing to share it.

ronjonp

  • Needs a day job
  • Posts: 7022
Saving at regular intervals
« Reply #5 on: April 12, 2005, 01:24:44 PM »
Sounds interesting Jeff, would you post it?

Thanks,

Ron

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Jeff_M

  • King Gator
  • Posts: 3942
  • C3D user & customizer
Saving at regular intervals
« Reply #6 on: April 12, 2005, 01:44:22 PM »
Quote from: ronjonp
Sounds interesting Jeff, would you post it?

Thanks,

Ron

Sure thing.....this code is placed in the ThisDrawing module of my acad.dvb. To ensure that acad.dvb gets loaded at startup, see the section in the Customization Guide, under the heading "Programming Interfaces -> Automatically Load and Execute VBA Projects"
Code: [Select]

Option Explicit

Dim command_count As Long

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
  '***Below code is to AUTO save the drawing every 25 commands,
  If ThisDrawing.GetVariable("DWGTITLED") = 1 Then 'don't use on new, unsaved drawings
  Select Case CommandName
    Case UCase("undo"), UCase("u"), Ucase("zoom"), Ucase("z"), Ucase("pan")
        command_count = command_count
    Case Else
        command_count = command_count + 1
        If command_count = 25 Then 'change this to any number you want
            ThisDrawing.Save
            command_count = 0
        End If
    End Select
  End If
End Sub

ronjonp

  • Needs a day job
  • Posts: 7022
Saving at regular intervals
« Reply #7 on: April 12, 2005, 02:22:06 PM »
Thanks Jeff.

Ron :D

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

CADaver

  • Guest
Saving at regular intervals
« Reply #8 on: April 13, 2005, 11:55:33 AM »
Quote from: jonesy
Does autosave do a full save to dwg format?
I was always under the impression that autosave was an emergency only option, and should only be re-named and used in the direst of circumstances.
You're correct, AUTOSAVE is for catostrophic failures only and should never be used instead of proper saving standards and procedures.  We "beat" into our users to save early save often and have set CTRL+S to run a qsave, and have qsave built into a couple of the more common buttons.

ISAVEPERCENT controls full save.

MP

  • Seagull
  • Posts: 17399
Saving at regular intervals
« Reply #9 on: April 13, 2005, 11:59:42 AM »
Quote from: CADaver
We "beat" into our users to save early save often and have set CTRL+S to run a qsave.

Indeed.

Good to see you posting Randy, hope you're doing well my friend.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

CADaver

  • Guest
Saving at regular intervals
« Reply #10 on: April 13, 2005, 01:12:03 PM »
Quote from: MP
Quote from: CADaver
We "beat" into our users to save early save often and have set CTRL+S to run a qsave.

Indeed.

Good to see you posting Randy, hope you're doing well my friend.
Hangin' in, typing's a bit... pain.. one finger each hand, aim and punch.  I'm hoping the exercise wakes up something.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15500
Saving at regular intervals
« Reply #11 on: April 15, 2005, 08:05:22 AM »
So, is there a method of timing in AutoCAD, or would there be a better way of saving automatically?

Many thanks
Thanks for explaining the word "many" to me, it means a lot.

daron

  • Guest
Saving at regular intervals
« Reply #12 on: April 15, 2005, 08:13:47 AM »
Go to help and look up TD. You should see a list of different sorts of timing variables that autocad is using that you can use.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15500
Saving at regular intervals
« Reply #13 on: April 15, 2005, 09:10:55 AM »
Many thanks, I will look into that
Thanks for explaining the word "many" to me, it means a lot.

ronjonp

  • Needs a day job
  • Posts: 7022
Saving at regular intervals
« Reply #14 on: April 15, 2005, 09:24:40 AM »
Jeff's save by number of commands works great.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC