Notifications
Clear all

[Closed] Timed Autosave

I want to automatically save scenes every 5 minutes, just like Autobak, but to the same .max file each time. Tried a simple Save script and used Task Scheduler, but, of course Windows and Task Scheduler don’t understand Maxscript. Any ideas much appreciated.

John Nixon

11 Replies
 rdg

johnnixon,

there is a interface control named “Timer”,
When enabled it fires a event after a specified time.
This could be a starting point for a script.

Georg

don’t want to hack the thread but i had i question in the same vein.
the autoback is control by a timer right? is it possible to reset the timer every time the user hit the save or save as button??
i dunno if i;m the only one but waiting X minute for a save and having the autoback Re-saving 30 sec after for another X minutes is pretty annoying.

rdg

Thanks for the suggestion. Had just started to look at Timer, which looks like the answer, when I downloaded a ready-made macro script from KenamicK. It has a problem at the moment, but will try to sort it when I get back from holidays.

Also Deadalus, thanks for your input. I shall have a look at avoiding the problem of double saves when I have cracked this little nesting problem.

Much appreciate the input from you both.

Kind regards

John Nixon

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

The trouble with the timer UI control is that you have to place it in a rollout somewhere.
I would suggest a simpler solution – you could register some simple callback script that reacts to general user interaction, for example selecting objects or something like that.

The script would work like this:

*When the callback is executed, the script checks the timestamp() value against the last known save end time.
*If the desired time in seconds has passed already (the time could be saved in an INI file to be easily changed without editing the script), then a COUNTDOWN will start – the callback function will create and open a small floater with a button, a timer UI control and a counter text saying: “About to save in … 10…9…8…”. You can press the button to SKIP the saving for another time interval or let it continue counting and save the backup.
*When the saving has finished, the dialog will store the CURRENT time from timestamp() into a global variable or in the INI file and then close.

This approach makes sure that the scene is saved only when it is really changing, and that you have control over the process and can cancel the backup before it happens if you are in the middle of an important operation that should not be interrupted. Also, it does not require a constant timer counting down, just one monitoring callback function that will only be activated if the user is actually doing something with the scene…

This is just an idea, feel free to implement it…

Evaluate this script (or put it in your scripts startup folder). It should reset the autobackup timer when a scene is saved manually

-- remove any previous callbacks
callbacks.removescripts id:#resetAutobackTimer

-- script to reset the auto backup timer
global resetAutobackTimerScript = "if autobackup.enabled then ( autobackup.enabled = false; autobackup.enabled = true )"

-- add callbacks
callbacks.addscript #filepostopen resetAutobackTimerScript id:#resetAutobackTimer
callbacks.addscript #filepostsave resetAutobackTimerScript id:#resetAutobackTimer
callbacks.addscript #systempostnew resetAutobackTimerScript id:#resetAutobackTimer
callbacks.addscript #systempostreset resetAutobackTimerScript id:#resetAutobackTimer

Cheers,
Martijn

Thanks gents

Magicm – just got back from a week away on holiday – haven’t had time to try your script yet. Afraid I’m a beginner at MaxScript, so will take a little time to understand it. Thanks a lot for your trouble

Bobo – yes, that’s just the problem I’ve found – don’t want a rollout sculling about all the time in precious viewport real estate. I tried to make a simple utility, which works fine and keeps the rollout out of the way in the utility panel – unfortunately stops saving when I leave the utility panel to work with modifiers. I followed your reasoning through, and will try to put something together along those lines, maybe integrating the ideas from Magicm. Thanks a lot for your help.

Kind regards

John Nixon

Hi John,

You can create a dialog outside your screen actually. Kinda like:

createDialog new pos:[-100,-100]

Light

I think i’ve found an autoback bug…

I’ve made a little script which displays a timer and pops up a message whenever you save. With the autoback set to kick in every minute, I’m using the “autobackup.enabled = false; autobackup.enabled = true” to reset it’s time at a certain time but it doesn’t work properly! If I am running the reset code 45 seconds after it autosaved, the autoback kicks in 30 seconds after this, not a minute as it is supposed to!!!

Any ideas?

Thanks,
Anton

[QUOTE=vasilescu_anton]I think i’ve found an autoback bug…

I’ve made a little script which displays a timer and pops up a message whenever you save. With the autoback set to kick in every minute, I’m using the “autobackup.enabled = false; autobackup.enabled = true” to reset it’s time at a certain time but it doesn’t work properly! If I am running the reset code 45 seconds after it autosaved, the autoback kicks in 30 seconds after this, not a minute as it is supposed to!!!

Any ideas?

Don’t use the autoackup variable. Under the hood it just calls the code that is implemented in the autosave interface (New in Max 9). I added a function to that interface that called .resetTimer() that does exactly what you are trying to do.

Anyways…

There is alot going on with autoabackup under the hood that I didn’t try to touch. Remember autobackup will not save anything if there is no undo stack. That means if you haven’t changed anything in the scene then autobackup will not do anything.

And in reference to someone elses question, I also made autobackup reset it self after a save operation (For Max 9).

Chris J.

 rdg

There is alot going on with autoabackup under the hood that I didn’t try to touch.

what does this imply?
I wrote a script – just missing an setup interface – that adjusts the autobackup timer against the file size.
psychosilence and me are testing this currently with max8 and it looks like it behaves as it should right now.

Is this not a good idea?

Georg

Page 1 / 2