CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-02-2018, 01:20 PM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Super Fast Autosave

I've been manually testing a much faster method of autosave, though admittedly it's currently much less user friendly. For testing I turn on autosave, with the 'ask before save' option; when it asks, I say no, then use file - save functionality. I'd like to take the next step in automating this; can someone help clean up my code (I'm still more of an ME Macro Language guy...) ? I'd like to get to the point that I can set two buttons in my toolbar to click these after saying no to autosave.
Code:
(in-package :valve)
(use-package :oli)
(defvar *AutoSaveIncrement* 1)																						;Loop counter
(defvar *AutoSaveNumberOfIncrements* 2)																				;How many backups do you want? 
(unless (sd-directory-p (format nil "~AAutosave" (sd-inq-temp-dir)))												;Check if an autosave directory exists in the user's temp directoy
  (sd-make-directory (format nil "~AAutosave" (sd-inq-temp-dir)))													;Make Autosave directory
)

(defun AutoSaveBaseline
  (defvar *AutoSaveBaseLocation* (format nil "~AAutosave/~A" (sd-inq-temp-dir) (get-universal-time)))				;Establish autosave location
  (sd-display-alert "Beginning Autosave" :icon :info :auto-close-time 5)											;Popup toast warning user what's up
  (sd-with-current-working-directory AutoSaveBaseLocation															;Remember CWD, change dir, run these things, revert to CWD
    (save_sd :OVERWRITE :all_at_top :TOP_LEVEL_INSTANCE_FILES :YES :DIRECTORY complete)								;Save all items using .sd format 
    (sd-display-alert (+ "Autosaved to " AutoSaveBaseLocation) :icon :info :auto-close-time 5)						;Popup toast showing location saved to
    (sd-copy-file AutoSaveBaseLocation (+ AutoSaveBaseLocation "BaseCopy"))											;Capture fallback copy of baseline save
; actually I think I want something like this: (oli:sd-sys-background-job "xcopy C:\\Users\\gregm\\Documents\\AutosaveTest\\20180412a %temp%\\20180412ab\\")
  )
)
 
(defun AutoSaveIncremental
  (oli:sd-display-alert "Beginning Autosave" :icon :info :auto-close-time 1)										;Popup toast warning user what's up
  (sd-with-current-working-directory AutoSaveBaseLocation															;Remember CWD, change dir, run these things, revert to CWD
    (save_sd_modified :OVERWRITE :all_at_top :TOP_LEVEL_INSTANCE_FILES :YES :DIRECTORY AutoSaveBaseLocation complete) ;Save all modified items - super fast 
    (oli:sd-display-alert (+ "AutoSave to " AutoSaveBaseLocation) :icon :info :auto-close-time 5)					;Popup toast showing location saved to
    (oli:sd-copy-file AutoSaveBaseLocation (+ AutoSaveBaseLocation "_" AutoSaveIncrement))							;Capture fallback copy of incremental save
  )	
  (if (= AutoSaveIncrement AutoSaveNumberOfIncrements) 																;Loop to capture fallback increments
    (defvar *AutoSaveIncrement* 1)																					;Reset to 1
	(+ *AutoSaveIncrement* 1)																						;Increment by 1
  )	
)
Just doing a "baseline" save instead of the standard autosave, is a great time saver, since I don't have to wait for the package file to zip (why don't they do that in the background?).
Reply With Quote
  #2  
Old 05-03-2018, 03:55 AM
Shaba's Avatar
Shaba Shaba is offline
Registered User
 
Join Date: Nov 2006
Location: Italy
Posts: 215
Re: Super Fast Autosave

interesting.
This a woking code?
My lisp skill is very poor
Reply With Quote
  #3  
Old 05-04-2018, 09:53 AM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: Super Fast Autosave

No, not yet working code :-(
Reply With Quote
  #4  
Old 05-08-2018, 08:56 AM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: Super Fast Autosave

Getting closer I think:

Code:
(in-package :valve)
(use-package :oli)
(sd-display-alert "Loading Autosave" :icon :info :auto-close-time 5)
(defvar *AutoSaveIncrement* 1)																							;Loop counter
(defvar *AutoSaveNumberOfIncrements* 2)																					;How many backups do you want? 
(defvar *AutoSaveBaseLocation* "Directory")																			;Establish autosave location variable

(unless (sd-directory-p (format nil "~AAutosave" (sd-inq-temp-dir)))													;Check if an autosave directory exists in the user's temp directoy
  (sd-make-directory (format nil "~AAutosave" (sd-inq-temp-dir)))														;Make Autosave directory
)

(defun AutoSaveBaseline
;  (oli::sd-display-alert (+ (oli::sd-inq-temp-dir) "Autosave/" (oli::get-universal-time)))	  
  (setf *AutoSaveBaseLocation* (format nil "~AAutosave/~A" (sd-inq-temp-dir) (get-universal-time)))						;Establish autosave location
  (sd-make-directory *AutoSaveBaseLocation*)																			;Create autosave location
  (sd-display-alert "Beginning Autosave" :icon :info :auto-close-time 5)												;Popup toast warning user what's up
  (sd-with-current-working-directory AutoSaveBaseLocation																;Remember CWD, change dir, run these things, revert to CWD
    (save_sd :OVERWRITE :all_at_top :TOP_LEVEL_INSTANCE_FILES :YES :DIRECTORY complete)									;Save all items using .sd format 
    (sd-display-alert (+ "Autosaved to " *AutoSaveBaseLocation*) :icon :info :auto-close-time 5)						;Popup toast showing location saved to
    (sd-copy-file *AutoSaveBaseLocation* (+ *AutoSaveBaseLocation* "BaseCopy"))											;Capture fallback copy of baseline save
; actually I think I want something like this: (oli:sd-sys-background-job "xcopy C:\\Users\\gregm\\Documents\\AutosaveTest\\20180412a %temp%\\20180412ab\\")
  )
)
 
(defun AutoSaveIncremental
  (oli:sd-display-alert "Beginning Autosave" :icon :info :auto-close-time 1)											;Popup toast warning user what's up
  (sd-with-current-working-directory *AutoSaveBaseLocation*																;Remember CWD, change dir, run these things, revert to CWD
    (save_sd_modified :OVERWRITE :all_at_top :TOP_LEVEL_INSTANCE_FILES :YES :DIRECTORY *AutoSaveBaseLocation* complete) ;Save all modified items - super fast 
    (oli:sd-display-alert (+ "AutoSave to " *AutoSaveBaseLocation*) :icon :info :auto-close-time 5)						;Popup toast showing location saved to
    (oli:sd-copy-file *AutoSaveBaseLocation* (+ *AutoSaveBaseLocation* "_" AutoSaveIncrement))							;Capture fallback copy of incremental save
  )	
  (if (= *AutoSaveIncrement* *AutoSaveNumberOfIncrements*)																;Loop to capture fallback increments
    (defvar *AutoSaveIncrement* 1)																						;Reset to 1
	(+ *AutoSaveIncrement* 1)																							;Increment by 1
  )	
)

(sd-display-alert "Done loading Autosave" :icon :info :auto-close-time 5)
I'm not sure why I'm getting an error about not being a symbol
Code:
(setf *AutoSaveBaseLocation* (format nil "~AAutosave/~A" (sd-inq-temp-dir) (get-universal-time)))
Reply With Quote
  #5  
Old 05-09-2018, 10:43 AM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: Super Fast Autosave

AutoSaveBaseline is looking pretty good
Code:
(defun AutoSaveBaseline ()
  (setf *AutoSaveBaseLocation* (format nil "~AAutosave/~A" (sd-inq-temp-dir) (get-universal-time)))						;Establish autosave location
  (sd-make-directory *AutoSaveBaseLocation*)																			;Create autosave location
  (sd-display-alert "Beginning Autosave" :icon :info :auto-close-time 5)												;Popup toast warning user what's up
  (sd-with-current-working-directory *AutoSaveBaseLocation*																;Remember CWD, change dir, run these things, revert to CWD
    (save_sd :OVERWRITE :CWD_CHANGED :SELECT :all_at_top) 																;Save all items using .sd format 
    (sd-sys-background-job (format nil "xcopy ..\\~A ..\\~ABaseCopy /I" (subseq valve::*AutoSaveBaseLocation* (- (length valve::*AutoSaveBaseLocation*) 10)) (subseq valve::*AutoSaveBaseLocation* (- (length valve::*AutoSaveBaseLocation*) 10))))
    (sd-display-alert (format nil "Autosaved to ~A" *AutoSaveBaseLocation*) :icon :info :auto-close-time 5)						;Popup toast showing location saved to
  )
)
Reply With Quote
  #6  
Old 05-16-2018, 03:34 PM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: Super Fast Autosave

Code:
#| Just doing a "baseline" save instead of the standard autosave, is a great time saver, since you don't have to wait for the package file to zip (why don't they do that in the background?). 
This sequence saves a baseline save using .sd? format to the user's temp directory. Current suggested usage is to turn on Modeling's Autosave function with the 'ask before save' option. When it asks
if you want to save now, say no, then use these tools. The first time per Modeling session you'll need to do AutoSaveBaseline; each baseline creates a copy upon completion to fallback to. 
Subsequent saves using AutoSaveIncremental will be substantially quicker; current code cycles through 3 copies of autosaves to fallback to. 

For best safety in testing phase, consider doing a new baseline save when heading out to lunch, a meeting, or other opportunity where the delay of the save won't be an irritation. This frequent number of 
copies of design space have the potential to quickly fill up your hard drive - OpenAutoSaveDir will take you to the Autosave base directory where you can delete old unneeded directories. 

To recover in the case of crash you can go to the most recent autosave directory, sort by file type and load .sd? files, i.e. .sdw, .sdp, .sda, etc. Don't load .sd?c files unless you are only after a 
particular instance of part/assy/WP.
|#

(in-package :valve)
(use-package :oli)
(sd-display-alert "Loading Autosave" :icon :info :auto-close-time 5)
(defvar *AutoSaveIncrement* 1)																							;Loop counter
(defvar *AutoSaveNumberOfIncrements* 3)																					;How many backups do you want? 
(defvar *AutoSaveBaseLocation* nil)																						;Establish autosave location variable

(unless (sd-directory-p (format nil "~AAutosave" (sd-inq-temp-dir)))													;Check if an autosave directory exists in the user's temp directoy
  (sd-make-directory (format nil "~AAutosave" (sd-inq-temp-dir)))														;Make Autosave directory
)

(defun AutoSaveBaseline ()
  (setf *AutoSaveBaseLocation* (format nil "~AAutosave/~A" (sd-inq-temp-dir) (get-universal-time)))						;Establish autosave location
  (sd-make-directory *AutoSaveBaseLocation*)																			;Create autosave location
  (sd-display-alert "Beginning Baseline Autosave" :icon :info :auto-close-time 5)										;Popup toast warning user what's up
  (sd-with-current-working-directory *AutoSaveBaseLocation*																;Remember CWD, change dir, run these things, revert to CWD
    (save_sd :OVERWRITE :CWD_CHANGED :SELECT :all_at_top) 																;Save all items using .sd format 
    (sd-sys-background-job (format nil "xcopy ..\\~A ..\\~ABaseCopy /I" (subseq *AutoSaveBaseLocation* (- (length *AutoSaveBaseLocation*) 10)) (subseq *AutoSaveBaseLocation* (- (length *AutoSaveBaseLocation*) 10)))) ;Assumes 10 character timestamp
    (sd-display-alert (format nil "Autosaved to ~A" *AutoSaveBaseLocation*) :icon :info :auto-close-time 5)				;Popup toast showing location saved to
  )
)
 
(defun AutoSaveIncremental ()
  (oli:sd-display-alert "Beginning Incremental Autosave" :icon :info :auto-close-time 1)								;Popup toast warning user what's up
  (sd-with-current-working-directory *AutoSaveBaseLocation*																;Remember CWD, change dir, run these things, revert to CWD
    (save_sd_modified :OVERWRITE :all_at_top :TOP_LEVEL_INSTANCE_FILES :YES :DIRECTORY *AutoSaveBaseLocation* complete) ;Save all modified items - super fast 
    (sd-display-alert (format nil "Autosaved to ~A" *AutoSaveBaseLocation*) :icon :info :auto-close-time 5)				;Popup toast showing location saved to
    (sd-sys-background-job (format nil "xcopy ..\\~A ..\\~A_~A /I" (subseq *AutoSaveBaseLocation* (- (length *AutoSaveBaseLocation*) 10)) (subseq *AutoSaveBaseLocation* (- (length *AutoSaveBaseLocation*) 10)) *AutoSaveIncrement*)) ;Assumes 10 character timestamp
    (sd-display-alert (format nil "Copied incremental to ~A_~A" *AutoSaveBaseLocation* *AutoSaveIncrement*) :icon :info :auto-close-time 5)				;Popup toast showing location saved to
  )	
  (if (= *AutoSaveIncrement* *AutoSaveNumberOfIncrements*)																;Loop to capture fallback increments
    (setf *AutoSaveIncrement* 1)																						;Reset to 1
	(setf *AutoSaveIncrement* (+ *AutoSaveIncrement* 1))																;Increment by 1
  )	
)

(defun OpenAutoSaveDir ()
  (sd-with-current-working-directory *AutoSaveBaseLocation*																;Remember CWD, change dir, run these things, revert to CWD
    (sd-sys-background-job "start ..")
  )
)

(ADD_TOOLBOX_BUTTON :TOOLBOX "TOOLBOX" :LABEL "AutoSave Baseline" :ACTION "(valve::AutoSaveBaseline)")
(ADD_TOOLBOX_BUTTON :TOOLBOX "TOOLBOX" :LABEL "AutoSave Incremental" :ACTION "(valve::AutoSaveIncremental)")
(ADD_TOOLBOX_BUTTON :TOOLBOX "TOOLBOX" :LABEL "Open AutoSave Dir" :ACTION "(valve::OpenAutoSaveDir)")

(sd-display-alert "Done loading Autosave" :icon :info :auto-close-time 5)
Reply With Quote
  #7  
Old 05-17-2018, 10:38 PM
Shaba's Avatar
Shaba Shaba is offline
Registered User
 
Join Date: Nov 2006
Location: Italy
Posts: 215
Re: Super Fast Autosave

Let me understand..
This Autosave is not automatic?
Reply With Quote
  #8  
Old 05-18-2018, 08:32 AM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: Super Fast Autosave

correct, it's not yet automatic. this is really just next step in proof of concept. It still relies on the out of box autosave to use as a timer/counter, but aims to reduce the pain of waiting for autosave to complete.
Reply With Quote
  #9  
Old 05-29-2018, 09:15 AM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: Super Fast Autosave

I've moved this code set to GitHub: https://github.com/barebuns/IncrementalAutoSave
I've added Annotation backup to the code as well.
I look forward to anyone's feedback on how this is working for them, and if they've had any unexpected behavior.
Reply With Quote
  #10  
Old 05-29-2018, 11:35 AM
tom kirkman's Avatar
tom kirkman tom kirkman is offline
Registered User
 
Join Date: Oct 2002
Location: Perrysburg, Ohio
Posts: 397
Re: Super Fast Autosave

Thank you

Once I get through with my current project, I will load it up and try it.

Tom
__________________
Tom Kirkman

Creo Elements/Direct 20.1
Dell Precision 3581
https://www.o-i.com
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 07:43 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.