CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization
Register FAQ Calendar Today's Posts Search

 
 
Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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

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 05:01 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.