Is automatically saving the opened file as scene if the rendered image gets saved possible?
Hi, I'm currently fixing my biggest issue that I constantly have:
"rendering a few dozens different poses of a character only to then want to go back and edit a few things in one of them and because I forgot to save the final version with that pose I have to recreate it again"
It literally happens twice daily, so now I am looking to create a script for DAZ that runs in the background and notices if I save a rendered image and then saves that open file under the same name that gave the just saved image.
Is this even possible and if yes can you point me in the right direction? Or do I have to find another way of doing things?
I have prior knowdledge of C# btw so you don't have to overly simplify explanations :)
Thanks in advance <3
Comments
You could write a script that saved and then launched the render, then use that to start rendering. See DzSaveFilter http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/savefilter_dz and DzRenderer http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/renderer_dz
Thank you very much for your answer, in the meantime I searched a bit more and stumbled upon this right here:
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/rendering/render_post_process/start
Could I just insert a script there that saves the scene which is open now under the name of the finished render?
Probably, I thought ypu wanted to save before the render in case of problems during.
I tried to do it with my very limited javascript knowledge and kind of failed...
Most of the code posted below is from here I just added 1 Line (marked by the comment "Directly below is the Line I added and which doesn't seem to work") hoping it would just save the scene under the name of the image but instead of doing that it literally does nothing with this line of code. It opens the image just fine (the line directly above) but it just won't save the scene.
Can anyone of you guys please help me out?
I think you need to use App.getSaveFilterManager() to get (a pointer to) the Save Filter Manager, then you can use saveScene( name ) on that - at the moment you are trying to use a global saveScene function, which doesn't exist.
Sorry, I pointed you to the wrong object for saving - that is for the older formats, and DS no longer writes .daz files. I should have sent you to DzAssetIOMgr http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/assetiomgr_dz . Rob has posted a sample for saving a scene http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/file_io/save_duf_scene/start
I don't know if I'm just confused, but the post processing script seems to open itself again when saving the preview thumbnail picture for the scene and I seem to get thrown into an endless loop. :)
Well, the thumbnail is a render. Looking at the dSaveWithOptions method there is a Boolean that can be used to save only the .duf file, with no thumbnail. http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/assetiomgr_dz#a_1a583b7d4a01c5dc84e3b80729636badab
Here's a quick example script to do this, it does not automatically save in the same location as the render, as the rendered image filename and the scene thumbnail filename will be the same.
// DAZ Studio version 4.12.1.118 filetype DAZ Script // To prevent processing thumbnails recursively we use a global variable. if (typeof (g_nPostProcessScriptInProgress) === typeof (undefined)) g_nPostProcessScriptInProgress = 0; (function () { var sSaveDirectory = "E:/"; try { if (g_nPostProcessScriptInProgress++ > 0) { debug ("Render post process script skipping apparent thumbnail (recursive depth: " + g_nPostProcessScriptInProgress + ")"); return; } // Get the filename of the first saved render var sFileName = getArguments()[0]; var oFileInfo = new DzFileInfo (sFileName); oFileInfo.setFile (sFileName); // Constructor is not doing this - why? sFileName = oFileInfo.completeBaseName(); // Get the filename of the scene to save sFileName = sSaveDirectory + "/" + sFileName; // Setup infrastructure to save a scene var oAssetIOMgr = App.getAssetIOMgr(); var oAssetIOFilter = oAssetIOMgr.getFilter (oAssetIOMgr.findFilter ("DzSceneAssetFilter")); var oSettings = new DzFileIOSettings(); oAssetIOFilter.getDefaultOptions (oSettings); oSettings.setBoolValue ("RunSilent", true); // Save the scene var oError = oAssetIOMgr.doSaveWithOptions (oAssetIOFilter, oSettings, false, sFileName); if (oError.valueOf() != 0) throw (getErrorMessage (oError)); App.log ("Render post process script saved scene: " + sFileName) } catch (oError) { App.warning ("Render post process script error: " + oError) } finally { g_nPostProcessScriptInProgress--; } })();
I just realized I missed an important use case. This script will not work correctly when saving a scene directly, so don't use as is! :)
I'd really like a way to tell if the post process script is being called for a thumbnail. Without being able to do so, I think this is the closest I can get...
You literally made my day, thank you so much, it works flawlessly from what I can tell :)