Return of the Auto back

Autoback is one of those features we love to hate… we love it when it saves our ass, we hate it when it interrupts what we are doing.  One of my main pains is when you open the autoback, you have to go through a resave it in the right place.  Someone asked me why it can’t know where to go back to so I thought I’d write a little script to do just that!

–Declare a persistent global which will stay with the file when we open it
Persistent Global g_OriginalFilePath

–It’s good practice to remove any callback scripts before adding new ones
callbacks.removeScripts #filePostOpen id:#dw_tools
callbacks.removeScripts #filePostSave id:#dw_tools

–lets make a new function which we will call using the callbacks
fn restoreFile =
(
–If the filepath of our maxfile matches our autobackup we know we’ve got an autoback file!
if maxfilepath == (Getdir #autoback) then
(
MessageBox “Please resave this autoback file in the original folder.” title:”God bless autoback!” beep:true

–if we’ve got an original path then bring up a save max window with the old path
if g_OriginalFilePath != undefined do
(
newFileName = getMAXSaveFileName filename:g_OriginalFilePath
if newFileName != undefined do saveMaxFile newFileName
)
)
else
(
–If not then we need to update the path so that it’s the latest file we’ve opened/saved
g_OriginalFilePath = maxfilepath + maxfilename
)
)

–Add a callback for opening / saving files to store our filepath and check when opening/saving
callbacks.addScript #filePostSave “restoreFile()” id:#dw_tools
callbacks.addScript #filePostOpen “restoreFile()” id:#dw_tools

Super simple, and will probably save a couple of hours a year for each max artist. All you need to do is put that in a maxscript file in your startup scripts folder which can be found either:
C:\Program Files\Autodesk\3ds Max 20xx\scripts\Startup
or
C:\Users\Sherlock.Holmes\AppData\Local\Autodesk\3dsMax\2016 – 64bit\ENU\scripts\startup

About davewortley

Somewhere between an artist and a programmer, I like technical things, but being creative. I love problem solving and coming up with elaborate solutions. This blog is where I shall share ideas, tips, tutorials and anything that amuses me.
This entry was posted in 3dsmax, MaxScript. Bookmark the permalink.

Leave a comment