Home Technical Talk

Maya Autosave?

polycounter lvl 14
Offline / Send Message
Maks polycounter lvl 14
:poly127: Now I lost again 2h of work,
my maya crashes everyday about 2-3 times.
Do you know how to autosave maya? i have version 7, 8.5 and 2009.

Replies

  • rebb
  • Funky Bunnies
    Options
    Offline / Send Message
    Funky Bunnies polycounter lvl 17
    there are a few scripts and plugins to do it, but they're all at least a little lame.

    as you can see from the script rebb linked, there are only options for Maya to check on the state of things after a state changes - you change selection or you change tool. So it's possible that even with a 2 minute autosave interval you wouldn't get a save in hours depending on what you're doing. That's just a limit of mel scripts. Any alternative would get too complicated and probably sacrifice performance. Also they'll usually just save over your current file as opposed to a variable number of extra files like max. I'm not sure why noone does this, because it's extremely easy :P

    This plugin shouldn't have a problem with intervals though - if I remember right. Probably your best bet is to get it from highend and set your saving to incremental. The plugin just saves over your current scene file unless they've made improvements, so if you set your saving to incremental it'll save a copy from each time you saved that particular scene into a folder.

    That gets heavy though :(
  • Rob Galanakis
    Options
    Offline / Send Message
    Anyone interested on doing a Maya autoback? I have a really good custom one for Max (in objective term's, Max's autoback sucks), I'd like to port over to Maya if any MEL person wants. MSN or PM me.

    .ms script is here: http://tech-artists.org/hg/robgalanakis/autoback/archive/tip.zip
    and the repo is here: http://tech-artists.org/hg/robgalanakis/autoback/
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    Rob, I may well be all over this. I wanted to do one for work anyway but a public port of yours is probably going to be nicer for everyone.
  • Mark Dygert
    Options
    Offline / Send Message
    I love your autoback script for max, that would be awesome if it was ported to Maya. I have it shut off and just make regular saves out of habit. Doesn't Maya save them to some gawd awful place with a weird name? Or did they sort out that BS? I remember it being more trouble then it was worth, hence the shutting it off...
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    Maya by default has no autobackup, Vig. It tries (and regularly fails) to save backup files if it crashes, it puts them in some horrible Application Data hidden folder in your Documents. The only other option besides most of the (frankly dire) existing scripts is to use Incremental Save, which is also horrible.

    Basically I've been meaning to do this for a while, but I'm lazy, so hopefully Rob's existing code will make it easier for me to make something good.
  • sama.van
    Options
    Offline / Send Message
    sama.van polycounter lvl 14
    hi guys.. Just awake then X_X...


    I already speak with Pior about that, but my AUtoback is "house work" then not perfecr.

    Basicaly you have to create an "_Autoback" directory in your aork directory.

    And evrytime you save your file, I create another save in this _Autoback directory.

    Basicaly when Maa crash on a save, it destroyed your saved file... But when Maya crash. he cannot save 2 times at the same time... the the last 2nd save is safe....


    Any, if you want I create something better (actually the _Autoback folder have to be created manually... Or the script will make you some joke and you cannot save your scene :D:D:)


    Becarful this script replace your Ctrl+S hotkey !


    nameCommand
    -annotation "SAMA_SaveMeCorrectly"
    -command "SAMA_SaveMeCorrectly ()"
    SAMA_SaveMeCorrectlyCommand;
    hotkey -k "s" -ctl -name "SAMA_SaveMeCorrectlyCommand";

    global proc SAMA_SaveMeCorrectly ()
    {
    string $fileName = `file -q -sn -shn`;
    string $tempName = "";
    string $tempName = "_Autoback/_" + $fileName;

    string $absolutePathFile = `file -q -sn`;
    string $buffer[] = stringToStringArray ($absolutePathFile, "/");
    int $bufferSize = `size $buffer`;
    $buffer[$bufferSize - 1] = $tempName;
    string $temptAbsolutFullPath = stringArrayToString ($buffer, "/");

    string $fileType = "mayaAscii";

    if (`gmatch $fileName "*.ma"` == 1) $fileType = "mayaAscii";
    else if (`gmatch $fileName "*.mb"` == 1) $fileType = "mayaBinary";

    file -rename $temptAbsolutFullPath;
    file -save -de 0 -type $fileType;

    file -rename $absolutePathFile;
    file -save -de 0 -type $fileType;

    print ("\nTempFile : " + $temptAbsolutFullPath );
    print ("\nFile : " + $temptAbsolutFullPath );
    }
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    sama.van: That's not really a true auto-backup like Max has, though. It's just a safety net for when it crashes on save. A lot of the time it can crash even when you weren't thinking of saving, and that's when a "true" autosave is needed.
    Also, your script is pretty ghetto, you're using a lot of gmatch and "manual" commands which Maya has built-in functions for (fileExtension macro, and file -q -sn -shn to name but a couple you should probably use instead of all those stringToStringArray and gmatch commands) In fact weirdly you're already getting the short scene name as $fileName but then using some other method to set it as a temporary buffer value later. There seems to be a lot of code duplication and unnecessary declaration of variables which are only used once immediately after they're declared.
    Personally if I want to release a script I'll try to make sure it's as user-friendly and clean as possible, also with tons of error-checking, to make life easier for whoever wants to use it. Currently yours seems like it actually needs more work and technical knowledge to make it work properly (like manually creating a folder? gah!) :/

    While I appreciate that you posted that script with good intent, I'd much rather people only got scripts which have been put together a little more... thoughtfully?

    I've got a refactored version of Rob's MaxScript working tonight, it uses a Python timer running in a separate thread (Rob's used .NET controllers, which I can't use in Maya), and there doesn't seem to be a better way to do it in Maya. This method avoids needing a scriptJob watching for user input anyway.

    Hopefully I can put up a proper version tomorrow once I've ironed out some kinks and added a proper options menu, etc.

    Also noticed that there were a couple of bugs in Rob's original maxscript, he's been informed of them and hopefully already fixed :)
  • Rob Galanakis
    Options
    Offline / Send Message
    MoP wrote: »
    Also noticed that there were a couple of bugs in Rob's original maxscript, he's been informed of them and hopefully already fixed :)

    It was only a bug if you're not specifying your filesize in microbytes, which, obviously, I was expecting!
  • sama.van
    Options
    Offline / Send Message
    sama.van polycounter lvl 14
    Is the code isbetter like that?



    global proc SAMA_SaveMeCorrectly ()
    {
    string $currentFile = `file -q -sn -shn`;


    if ($currentFile != "")
    {

    string $directoryBuffer[] = stringToStringArray (`file -q -sn`, "/");
    $directoryBuffer[(`size $directoryBuffer` -1)] = "_Autoback";

    string $backUpDir = stringArrayToString ($directoryBuffer, "/") + "/";


    if (!`filetest -d $backUpDir`)
    {
    sysFile -md ($backUpDir);
    }


    string $fileType = "";

    if (`gmatch $currentFile "*.ma"` == 1) $fileType = "mayaAscii";
    else if (`gmatch $currentFile "*.mb"` == 1) $fileType = "mayaBinary";

    string $fullPathFile = `file -q -sn`;

    file -rename ($backUpDir + $currentFile);
    file -save -de 0 -type $fileType;

    file -rename ($fullPathFile);
    file -save -de 0 -type $fileType;


    print ("\nFile : " + $fullPathFile);
    print ("\nTempFile : " + $backUpDir + $currentFile );

    }

    else

    {
    confirmDialog

    -title "Error"
    -message "Please Save Your scene Manually first"
    -button "OK";
    }

    }
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    That seems a lot better, yes :)
  • claydough
    Options
    Offline / Send Message
    claydough polycounter lvl 10
    I did not realize autosave was so complex?

    FunkyBunnies, as far as I know the only reason u wouldn't get an autosave for hours is because yer not doing anything? In which case what would need saving?

    Mop, what is wrong with incremental saves? Do you mean incremental saves that aren't copys?

    Otherwise, My Ass Saver since 2000 by Andy J Rawlings: link

    makes back up copys of yer scene without interrupting workflow ( transparent: no currentTool or selection mode changes )

    I usually set the max file size pretty high so I can use the Backup directory as a timlapse reference

    Edit: Because of Maya 2009's new interactive main menu building. The file menu in ajrAutosave.mel would have to be hacked to work. link.
    otherwise u cannot use userSetup.mel to build the file menu.
    .
  • glib
    Options
    Offline / Send Message
    Anyone interested on doing a Maya autoback? I have a really good custom one for Max (in objective term's, Max's autoback sucks), I'd like to port over to Maya if any MEL person wants. MSN or PM me.

    .ms script is here: http://tech-artists.org/hg/robgalanakis/autoback/archive/tip.zip
    and the repo is here: http://tech-artists.org/hg/robgalanakis/autoback/
    What improvements does your script make, and how would I go about using it?
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    claydough: That script by Andy Rawlings looks pretty good. I guess now the one I'm doing is just an exercise in refactoring ;)

    Autosave itself is not that complex, but there are some slightly nice features you can have, like not running scriptJobs in the background watching every selection change, and actually being able to save regularly every 5 (or whatever) minutes. Also Rob's script actually sorts the autoBack files by modified date before overwriting/cleaning up, so you potentially end up with a better backup set. AJR's looks like it just overwrites the next number regardless of whether it was newer or older than the previous file.

    As for incremental saves, I don't like them because they don't really help you with anything if Maya crashes somewhere, like if you don't save for half an hour, then there's no difference between opening an incremental save, or your last saved scene, since they're both identical. It'd only be useful if you wanted to keep a "history" of your work really.
    I tend to use version control (at work and at home) so incremental saves are essentially useless to me.

    And hey, variety is the spice of life ;)
  • claydough
    Options
    Offline / Send Message
    claydough polycounter lvl 10
    Thanks MoP, but now I am so confused my head hurtz?

    under what conditions would an "auto" incremental save happen, that it would not have new data compared to a manual save?

    1. u didn't change anything in the time specified... then nothing is lost either. Crash doesn't matter?

    2. The time of crash was under time specified as autosave... Then I lost what I designated was acceptable. Crash is acceptable
    ( it is amazing how precious 30 minutes becomes when u lose it! as if the stars would have only aligned for that brief amount of time and all your edits could never be recreated as well. ever. )

    3. I am overlooking something and am about to be schooled:)
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    Heh, no, I think we have a misunderstanding here. I am not talking about incremental save. Ignore that completely. "Incremental save" and "autoback" are essentially two completely different things. "Incremental save" is what Maya saves whenever you hit CTRL+S if you have the Increment option enabled. "Autosave" should be something that happens automatically regardless of what the user is doing or has been doing.

    In this case, the script you linked fulfils the 2nd criteria, it "autosaves" after a certain time. You are correct that since it's a scriptJob, it will only call the "autosave" function immediately after an event that the scriptJob is hooked up to, and when the timer criteria is fulfilled. For the vast majority of cases, this is fine, since as you say if you didn't change anything under the time specified, then nothing is lost.

    HOWEVER! The one case where this does not hold up, is for example if my autosave time is set to, say, 10 minutes... in Max, if I start it up, load a scene, and start editing the scene, it will save every 10 minutes regardless of what I'm doing. Even if I'm away from the computer. This means if I do 9 minutes of work, then leave the computer, it will still autosave.

    All of the existing Maya autosave scripts will not do this. If I work for 9 minutes with a 10-minute autosave, then leave the computer, it will never autosave because I am not there to do any action which would cause the scriptJob event to be called. So basically if something weird happened and I worked 1 minute (or 1 second, whatever) under the timer, then stopped doing anything, I will never get to the next autosave step.

    Granted it's an edge case, and probably not a huge deal, but personally I'd prefer something that's going to save no matter what. Make sense?

    It's a tiny, nitpicky detail, I know... in the vast majority of cases the script you linked would be perfect, and in fact who even cares if you lose 9 minutes and 59 seconds of work if you happened to stop using the computer just before the autosave timer clicked?. But you should get what I mean, I hope.
  • claydough
    Options
    Offline / Send Message
    claydough polycounter lvl 10
    yes my head feels better already!

    Maya 2009 friendly userSetup.mel code fer ajrAutosave.mel:


    // Roger cly_doh's Maya 2009 file menu friendly ajrAutoSave
    string $mayaVersion = `about -version`; // cuz fer some reason `getApplicationVersionAsFloat` won't return here
    if ( `gmatch $mayaVersion "2009*"` ) {
    string $cmd = " buildFileMenu(); ajrAutoSave; ajrAutoSave; "; // repeated. once fer creation and again for window launch
    scriptJob
    -runOnce true // scriptjob dies on execution "menuItem will survive new scenes and menuMode changes"
    -event "SceneOpened"
    $cmd;
    }
    else {
    ajrAutoSave;
    ajrAutoSave; // repeated. once fer creation and again for window launch
    }







    hmmm for some reason polycount code wasn't playin nice?
  • glib
    Options
    Offline / Send Message
    Anyone interested on doing a Maya autoback? I have a really good custom one for Max (in objective term's, Max's autoback sucks), I'd like to port over to Maya if any MEL person wants. MSN or PM me.

    .ms script is here: http://tech-artists.org/hg/robgalanakis/autoback/archive/tip.zip
    and the repo is here: http://tech-artists.org/hg/robgalanakis/autoback/
    I took a guess and dropped your script in my Scripts/Startup folder. I'm running vista which should already include the .NET 2.0 framework (at least thats what it told me when I tried to install it from the MS site) and I installed the 3.5 RC1 framework after I started getting these errors, but the errors persist:

    I don't get a splash screen or dialogue, although reading through the script makes me think that I should ("Thank you for using tech-artists.org Autobak. This is the only time you will see this message."). When I type 'autoback.doc()' into the Listener I get:



    -- Error occurred in docQuery(); filename: C:\Program Files\Autodesk\3ds Max 2009\scripts\startup\autobak.ms; position: 8501
    -- Frame:
    -- qArr: #("Thank you for using tech-artists.org Autobak. This is the only time you will see this message.
    ", "Autobak is a replacement to Max's Autobackup, and disables it (make sure to re-enable it if you uninstall).", "Autobak runs seperate autoback 'threads' for different files (they are named accordingly and
    multiple open files will all backup correctly).", "Autobak also interpolates between a 'min backup time' and 'max backup time' based on the filesize, all defined in the autoback.ini file.", "When the filesize is the minBackupSize or smaller, the backup time will be minBackupTime (in minutes).", "The reverse is true for maxBackupSize/maxBackupTime.", "maxAutobackFiles determines the maximum number of autoback files for ALL files (not just the current file), so set it high.", "The autoback.ini file and all autobacks are located in your current max autoback folder (where your usual max autobacks go).", "Alternatively, you can type 'autoback.editini()' to edi the ini, and 'autoback.openfolder()' to open the autoback folder.", "You can launch this documentation by typing 'autoback.doc()' in the Listener.
    ", "Please report any bugs to robg@robg3d.com.
    ", "If you click on 'Yes' you will open the Autobak ini file for editing, 'No' will use the default values.")
    -- called in doc(); filename: C:\Program Files\Autodesk\3ds Max 2009\scripts\startup\autobak.ms; position: 8568
    -- Frame:
    -- Unknown property: "join" in undefined




    'autoback.openfolder()' and 'autoback.editini()' return true and work as expected.

    My problem is that I get popup windows periodically that say: "Unknown property: "zfill" in undefined" and the Listener reports this:




    -- Error occurred in doSave(); filename: C:\Program Files\Autodesk\3ds Max 2009\scripts\startup\autobak.ms; position: 5201
    -- Frame:
    -- targetPath: "D:\portfolio projects\starcraft rifle\autoback\autoback_high"
    -- suffix: 0
    -- called in doTick(); filename: C:\Program Files\Autodesk\3ds Max 2009\scripts\startup\autobak.ms; position: 5473
    -- Frame:
    >> MAXScript dotNet event handler Exception: -- Unknown property: "zfill" in undefined <<


    There are no autoback files saved in the autoback directory.


    Apologies for the hard-to-read post, the CODE tags seem to strip backslashes.
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    I guess strops is missing? I saw this strops stuff declared in the .ms and asked Rob about it, he seemed to indicate it was meant to be there, but I thought it looked a bit odd, like an external dependency.
    I don't really know much about it though, Mr. Galanakis is the man for that.
  • Rob Galanakis
    Options
    Offline / Send Message
    Yeah my bad, I thought I took that out- it is a library dependency. I'll try to fix it this weekend, really I just need a good way to auto-distribute the dependencies (actually we were doing work on something like this but it got sidetracked).
  • Killbot
    Options
    Offline / Send Message
    Otherwise, My Ass Saver since 2000 by Andy J Rawlings: link


    Hey guys, I'm new to this forum. And actually, despite my field, this is one of the first forums I've ever joined. So I apologize if my etiquette lacks from time to time. If I do anything taboo just let me know!

    Plus, I've been using Mel to introduce myself to programing. So I probably mess up things in that department. Don'cha love me?

    Anyway, Claydough, I'm using the ajrAutoSave v 1.3 script with Maya 2008 (64 bit if that matters) and I've run into a few problems. It worked great when I first ran it. saved backups and everything. But for one reason or another it has started getting stuck in the saving process. It gets to 100% on the save and just gets stuck. If I look at my Autobackup files I have two files that have been created with the save: 1) is labeled correctly but 1/6 the file size it should be and, of course, currupt and 2) another that is the proper file size but with a .mba04444 extension.

    I can delete the .mba04444, give it a .mb ext and open it just fine. But it appears to have problems with unhiding layers now (gets stuck calculating).

    Any advice?
  • efosanice
    Options
    Offline / Send Message
    Computer-local disk-users-username-Appdata-local-temp, you'll find the file there.


    I'm using an autodesk 2013
Sign In or Register to comment.