readable/editable source CC BY 3.0: incremental auto save script

velananashivelananashi Posts: 12
edited July 2018 in Freebies

Correction of License:

---
            
License: CC BY 3.0 (https://creativecommons.org/licenses/by/3.0/), since I can't make it completely free, because it is based on the following scripts using that license:
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/general/singleshot_timeout/start
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/file_io/save_duf_scene/start
            
According to Richard Haseltine those samples are likely written by Rob Whisenant who was working at DAZ 3D at the time. Thanks to Rob and DAZ 3D for the samples that helped me make this modified script.
            
Those scripts have been modified, possibly considered heavily, and combined by me, to achieve the result I wanted, I was not asked to do so by the original script maker(s), nor did I ask them permission to do so, the changes and amalgamation are entirely my own idea. I only needed to figure out if and how to do what I wanted to do.

---

Original incorrect post below, you may not do modifications beyond what that license above allows, but I keep the original text here to not hide what happened.

---

As I said over in the feature request thread Auto save (again):

"I have cobbled together an incremental auto saving script, in daz script, and I will attach it to the post, I hope it is useful to someone, it is of course not a feature of daz itself, that would be much better if it was added.

I am not a regular Daz Studio user myself, I just made it for a friend, nor am I a previous daz scripter, but it works as I want it to now and I thought why not share :)

It will require editing the script to update its settings to fit your own needs, and you should read at least the comment, but preferably the whole script before you use it, so you know I am not trying to do something evil, since that is entirely possible to do from daz scripts.

Maybe one of the better non rusty non newbie daz scripters on the forum can write a much better version of it. Also you will have to excuse my bad humor in the comment.

The script feels clunky, newbish, and probably breaks every style rule there is (but this is how I write code).

Also please change it as much as you like, and all that.

Also any admin/moderator, if this would be better someplace else, feel free to move it.

I probably will not be monitoring this thread or forum though. I only post it here since it was one of the newest threads on the subject that I found when looking for auto save feature for Daz, and did not get the answer I was looking for, so I had to learn the basics of Daz scripting and then cobble together sample code into something new.

I will stop babbling now, I hope it helps someone :)"

Just going to add that the way it saves incremental is by moving/copying the old currently open/last saved file to a user specified directory with the same file name, only with the date and time it was saved appended to the name (with high precision time in stripped ISO date format), and then if that succeeds it will tell daz to save to the original filename, if a move/copy to that user specified folder can't be done it instead tries to save to a file with same name as as the currently open/last saved file, with the curent time in (in stripped ISO date format) to the user selected folder directly. If you have started the script, and changed things to an entirely unsaved and therefore unnamed scene it will save that to a file in user specified directory, with the name simply being the timestamp, and after it does that it will save that one incrementally with another time stamp appended to it, better than losing work when you forgot to save, but not exactly pretty that last one. Feel free to edit the script to work differently though. Do edit in a user specified directory and choose how often you want it to save. If you do not choose a directory it saves incrementally under "*user libraries folder*/Documents/DAZ 3D/Studio/My Library/Scenes" or at least that is the path it saves to on my computer.

That is all, and the reason I post it again is that I noticed that the thread I posted to did not get bumped by the post, so I doubt anyone will notice until they search for auto saving and end up there (it is not even the top result for auto saving so I doubt most would get that far).

If I do any improvements to it, I will try to post the updated script here, but for me it is pretty much done now, if anyone else improves the script or writes a better script that does what this does better or with more features, I would ask that you please post a link to it or the actual script here and to that other thread, so others can use the improved script, I am not however demanding that from you, it would just be a nice thing to do for your fellow creators.

What I am hoping posting this will do is to reduce the number of times people like my friend, and all the other creators here lose their work, by implementing in a script a feature many have requested be added to Daz Studio itself, I really hope this feature can be added to Daz Studio directly, since with actual non scripted coding and a user interface for options, it would be a whole lot better, maybe it could even do it in a separate background thread without briefly popping up the save indicator, so that the user can just continnue work without noticing.

---

Current Version: 0.0024alpha

dsa
dsa
VNIASS.dsa
14K
Post edited by velananashi on

Comments

  • Tim NTim N Posts: 193
    edited July 2018

    Thanks for this. It worked as advertised for me.

    When I exited Daz, though, I got a fatal error message: "Daz Studio has encountered a fatal error, and must close".

    Post edited by Tim N on
  • The first version of this I made made a "corpse" of Daz linger in memory at 100% cpu on one core, and ever growing ram usage, I managed to get that problem removed, this morning I found out that running it from auto start leaves a passive "corpse" that keeps ram but does no cpu activity, I really have no clue why that happens, or how to solve it, but not running it as auto start script does not cause that problem for me. I am still like a few days old when it comes to Daz scripting, so maybe we can get a Daz script veteran in here to figure it out. As for your problem, I have no clue if that could be caused by my script or just a fluke. I hope it is not causing any damage though, since that really is not my intent.
  • Tim NTim N Posts: 193

    Thanks for the reply. No drama.

    You're doing good work for someone who's just started Daz scripting.

  • Thanks :) Hopefully I will have time to revisit the code and clean it up more in the future, it would be so much better if it would be able to run from autostart without causing lingering Daz in memory, might require more than one script file then though, but I am not sure. I do not really know why Daz ends up lingering like it does in the current version when the script is in auto start, I might need to try to formulate a question for it on the techie forum, once I have time to spend on actually implementing any fixes they suggest for me. Till then this version does what it needs to, it may not be pretty, but it works, so it will have to do.

  • Richard HaseltineRichard Haseltine Posts: 96,884
    edited July 2018

    Please note a script derived from one or more of the sample scripts cannot be made open source, it must be distributed in accordance with the license terms of the sample script - Creative Commons 3 by attribution.

    Post edited by Richard Haseltine on
  • velananashivelananashi Posts: 12
    edited July 2018

    Ah then I need to correct that, and upload a new version with that in the comment, and I rename the thread too. Did not think to do it because the license was not mentioned in the samples I downloaded and worked on and I forgot. I hope that can be forgiven.

    The updated file is in the first post. I can not easily see who wrote the samples, so the best I can do is link directly to their pages, and also to the CC BY 3.0 license, from the comment at the top of my script.

    Post edited by velananashi on
  • Of course I uploaded the old version by mistake in the post above this one... Sigh I can be so derpy sometimes... The correct one should be attached to the first post of the thread now however, and once I see the post above clear moderation queue I will delete the old script from it and refer to the top post instead.

  • Also I have to ask, from how I understand CC BY 3.0 it allows code to be open source (as in readable and modifyable by others) if this is not the case then nobody can have this source file and my thread should simply be deleted as clearly it is doing something horrible and breaking the rules. However then the sample code probably can't be in accordance with it either since it is available for others to read and edit. I hope that is not the case though. All I wanted to do was help creators not lose their work, by giving them incremental auto saves.

  • It's fine for the script to be readable, but saying something is open source allows it to be modified and distributed by others (depending on the license used), going beyond the license for the script samples. As far as I know all of the samples are by Rob Whisenant.

  • I do not think that is disallowed by CC BY 3.0 for others to read and modify and distribute their modifications (even commercially), if it is not then I can not do the same to the samples, and thus posting this in the first place is wrong, and the thread should be deleted.

    I think "Open source CC BY 3.0" in the title and the license blurb is good enough. I will edit in that you informed me the samples are all most likely by Rob Whisenant into the license blurb though. Give me a few moments to correct that and upload the new script. For me open source means not encrypted or hidden or compiled code. But I guess I could spell that out instead in the thread subject as "readable/editable source CC BY 3.0: incremental auto save script" so I will do that too.

    If that is not good enough, feel free to delete this thread, as I think I can't possibly live up to rules I do not understand.

  • WendyLuvsCatzWendyLuvsCatz Posts: 37,822

    this happened with Singular Blue's Genesis 3 to 8 script too

    I know nothing about scripting but why do DAZ include examples in their documentation if it's not meant to help people create scripts for DAZ studio?

    It is not like those scripts could be used for anything else but DAZ studio or enabling Studio to work with other stuff.

  • I may try a complete rewrite sometime later from just the API and not using the samples as guides, as I know more about how to do things now, of course a few lines will be very similar in those scripts, and I am not exactly feeling like doing more work on Daz scripts right now. So I still say this thread should be deleted if I am not following the rules/license now, and if it is you may just as well search for my other post and delete it too, and I will take the hint and not come back.

    If that is the case I am sorry to anyone who might have wanted this script. Though most would not have seen this yet, but yeah... I guess we will see.

    I may also try to find and poke Rob Whisenant, ask for permission or to check if what I did is okay, I have no clue how to do that though, and if he wants to be poked about things like this. Sounds like a waste of his time though.

  • nonesuch00nonesuch00 Posts: 17,929

    @velananashi I went directly to the example code used by the you and looked at your latest source code alterations and citation of your changes and so you are good to go as you follow the terms of the license:  

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/general/singleshot_timeout/start

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/file_io/save_duf_scene/start

    and directly above the source code at www.daz3d.com is a license "CC Attribution 3.0 unported" granted along with a link to the terms of a "CC Attribution 3.0 unported

    Who to Attribute? Even if the code were written by Rob Whisenent he was working for DAZ 3D so it is DAZ 3D who gets the attribution. The examples reside on the DAZ 3D business web site. 

    The example code cites no other license or authors therefore DAZ 3D is the author one attribute the code to and only under the terms of CC Atribution 3.0 unported which states in summary:

    You are free to:

    • Share — copy and redistribute the material in any medium or format
    • Adapt — remix, transform, and build upon the material
    • for any purpose, even commercially.
    • This license is acceptable for Free Cultural Works.
    • The licensor cannot revoke these freedoms as long as you follow the license terms.
    • No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

    Notices:

    • You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
    • No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.

    +++++

    Link to the "human-readable" (creativecoomons.org's words not mine) summary of the license:

    https://creativecommons.org/licenses/by/3.0/

    Link to the full terms of the license:

    https://creativecommons.org/licenses/by/3.0/legalcode

     

  • velananashivelananashi Posts: 12
    edited July 2018

    Thank you for checking on it for me nonesuch00 :)

    I will just make a very small adjustment then to make it clearer DAZ 3D is attributed, and otherwise leave things me. I will upload that comment fix in a few moments.

    First post and source file updated with comment changes regarding license, and also added a known bugs section.

    Post edited by velananashi on
  • th3Digit said:

    this happened with Singular Blue's Genesis 3 to 8 script too

    I know nothing about scripting but why do DAZ include examples in their documentation if it's not meant to help people create scripts for DAZ studio?

    It is not like those scripts could be used for anything else but DAZ studio or enabling Studio to work with other stuff.

    They are intended to help people, but that doesn't mean they can be used in a way that exceeds the (very broad) scope of the license - which requires attribution, and doesn't allow releasing the modified version with less restrictions than the original sample.

  • Just to be clear: while Rob is, no doubt, appreciative of your gratitude for the work he does on the scripting docs (samples and object references) his stipulation is that the attribution point back to the samples, rather than name him as such - he created them to teach others and so wants people to be able to go back and learn in their turn (which doesn't mean that the derivative scripts cannot be encrypted).

    Also, I mis-stated on the "cannot be open source" - what I meant to stress was that the terms of the derivative script cannot relax the license beyond that of the sample(s), but as long as they are consistent with and maintain the terms of the license they can indeed be open source.

  • The comment at the top of my source that I have also pasted at the top of the thread here:

    1. links back to the sample scripts I used.

    2. attributes Rob with the original scripts.

    3. mentions that he worked at Daz when he wrote them, and in so doing attributes it to them.

    I think I have done all I need to do, also he should appreciate the code remaining viewable and editable rather than encrypted, as more people can possibly learn from it in turn.

    If not the option is open for any admin or moderator to obliterate this thread, and if so preferably all my posts on the forum, one of them is not contained in this thread and links here and would be stupid to leave behind if this one is obliterated.

    Even if yes I could encrypt the script, but that goes against my desire for people to improve upon or make a better version of this script, or learn from it, seeing how I do what I do can likely make a better Daz scripter able to easily make a better script, then again it is a super simple script for a good Daz scripter to make I am sure. Also if I were to encrypt the script I would also have to add some sort of interface for changing configuration and saving the configuration someplace, rather than have users edit in the configuration options into the script itself.

    Really I want this script I made to inspire a better one, or be replaced by making the same feature part of Daz itself, where in all honesty it belongs, given how often I hear of Daz corrupting the save file or crashing on people, making them lose either the entire project, if they don't keep versions, or at lots of time depending on if their last save works or they have to go back to the version before then, it would be much better if Daz kept several old saves around so there was an option to find one close to where you were when things went wrong, that happening to a friend is why I made this script in the first place.

    If I were to implement this into Daz itself I would add a copy on write mechanism, so I can quickly create a shallow copy of the data to be saved, then completely in the background in a separate thread, save the data to a new file, rename the current file to have a time stamp indicating when it was saved, then rename the new file to have the filename of the current file, that way there is not even a few seconds of disturbance of the user while things are saved, just a gentle rattle of mechanical hard drive if they have that, and they can keep working (copy on write would not alter the structure being saved and would only alter the next save), finally when the shallow copy is nolonger needed any things deleted or changed since it was made would lose their old data as the shallow copy is removed.

    I have yet to bother trying to research why Daz remains lingering when this script is loaded from autostart, but not if started through double click or by being loaded into script editor and ran from there, I have a few ideas on what might help, like putting a script in autostart that somehow loads this script via some mechanism after it terminates itself, if such a mechanism exists for Daz, though I have not tested if any auto start script will leave Daz in memory after it closes, it might, and in that case there is nothing I can do about that.

    Anyway if this script helps someone good. I will shut up again now though.

  • Cris PalominoCris Palomino Posts: 11,151
    edited July 2018

    I've been using your script which has been very useful. Thank you.

    Somehow, I didn't realize that it would not only autosave to the folder in My Library, but it is saving over my working files, I am guessing this is the incremental part of the script. Under normal circumstances, it would be fine, but sometimes I use one file to start a variation. Then I realized the variation I was making supplanted my original file with the changed one. In order to preserve my original, I need to quickly save the file under a new name before it saved over my original.

    Is there a way to have a variable in the script where we can stop the incremental save, if needed, and only utilize the auto-save.  What I've noticed is that I have to restart the script for auto-save, but the incremental seems to just continue throughout. Is that intended?

    Post edited by Cris Palomino on
  • I am glad the script has been useful :)

    Your original file will be somewhere in your backup folder by some timestamp, but in your case it does sound a bit annoying that it does that when you are just experimenting, the manual solution to that is to save the file you are going to experiment with under a new name, but I suppose that is not very convenient so trying to get my brain to do a little bit of coding to add that option for you, to directly save to backup folder only, not over the original filename after moving the original to backup folder, but it will change the title for each save then, and that is not very pretty.

    The way the script currently works, and it is how it is intended to work:
    1. rename/copy last save to backup folder with a timestamp
    2. if successful save current scene onto original filename (so that the name is preserved in title)
    3. otherwise save directly to backup folder, creating a name with the original filename and then the timestamp
    the problem with 3 is that it can end up chaining filenames filenametimestamp1timestamp2timestamp3 etc if the files can never be renamed.

    Too many minutes later:

    I have updated the script in the top post with a new version that when the noRename option is set to true that tries to remove the last timestamp if the filename has one before putting the new timestamp in place, and also only saves autosaves to backup folder, changing the name in the title, and not renaming the file to have the same name constantly. This is the closest approximation I can get to what you asked for Cris Palomino. I don't use the new logic for the old saving system though, might try to put that in there, but I don't like how clunky it got, as I repeatedly failed to do regex correctly, and had to resort to a silly way of detecting timestamps by the distance of capital T and Z.duf respectively. Sadly that will match anything at end of file that has T and then ten characters later Z.duf, so not a good solution, best I can do though. Tested it and it performs as expected. With and without the option set.

    Sorry for being about as clear as tar in what I wrote above, current temperature in my home is 40C (higher than body temperature)... Thinking and formulating words is difficult, the code I wrote does what I expect it to do, but is not pretty. If you understand scripts you can sanity check it yourself or just see if it does what you expect it to do with a manual backup copy.

    Also since my script lacks a GUI it can't have its settings changed during running as far as I know, so you would have to restart Daz after editing the file with new options, and restarting it, I don't know if the script can be terminated when it is running either, it has no mechanism for that built in, and I don't think you want more than one of these running at the same time, I am not sure what would happen if that was done.

  • This script sounds like it's on the right track but still has a few kinks. I am working to deadlines or I'd give it a try--I'm hoping that others will be able to test and continue to work with you, velananashi, to refine it. As a creative, one often gets caught up in the moment and then, instead of relishing the joy of creation, we face a crushing loss (ok that was a bit over the top).

    Still, it is easy to lose yourself in a project, especially if you work, as many do, in other programs that all have customizable auto-saves or background saves. Sometimes, when working with several programs like Zbrush and Photoshop in conjunction with DS it's tough enough just keeping track of the wildly different navigation tools, and commands that mean something different in each program and destructive editing (as in some aspects of Zbrush) vs. non-destructive editing (as in Photoshop) vs. not sure if that is undoable or not (as in DS).

    It would be nice to have one less thing to keep track of.

  • velananashivelananashi Posts: 12
    edited July 2018

    In either mode this script always preserves the past saves, it just changes their names at worst, so it should always be possible to go back through the various saves to find the one that has the state one wanted, I know for certain that I will have to improve upon the date stripper for the non renaming mode, as it is not perfect (it can strip non dates too).

    I would however prefer someone who uses Daz regularly and writes scripts in it to write a better script and let mine retire, or better yet for this feature to be added to Daz in a better way than a script can do, although mine works, it is extremely basic and not super user friendly, since it requires users to edit its code to change configuration, and also seems not able to run in the auto start, because that for some reason causes Daz to remain in memory after closing... So users have to start it after starting Daz and that is not ideal (then it for some reason will not make Daz linger in memory), since having users have to remember to start it each time they start Daz is not great design. At any rate this is a low priority for me, as I do not use Daz myself. Despite that I have been more active here than I intended to be, and in the beginning mostly to deal with negative interaction, it did not make me want to care about improving this script more, positive interactions might help me feel motivated to improve it, I am not really sure how often I will update it though, or how often I will check in here, it already serves the purpose it was made for as is, currently motivation to do anything more to this script is very low.

    I know the feeling though at being in the creative moment and forgetting other things than just creating stuff, and perhaps not keeping as many saves as one should, luckily for me I work with text mostly, be it writing or source code, and the program I use for that keeps backups almost the same way my script here does for Daz, and it is very useful, though the text editor does not auto save, but it lights up a diskette icon when a change needs to be saved and I find that icon annoying and click on it, thus saving the changes, and when I do that it renames/moves/copies the old save to the backup folder with a timestamp, and then saves to the original name. I can always go back when I need to, of course text files tend to be smaller than Daz scenes, so I have yet to delete any of the backups stretching back years. Anyway thanks for your interest ace. If you end up using the script, I hope it works close enough to how you want it to, and saves you from any/many losses on the daz side of things.

    Post edited by velananashi on
  • Hello there.

    I just wanted to let you know that this script has saved my ass *countless* times when Daz crashed and I had last saved a century ago.

    Thank you!

  • 1. Does the script still work with 4.21?
    2. Where do you "install" it? In the Script folder?

    Thank you!

Sign In or Register to comment.