Batch Subset loader / scene fixer
Hi everyone, I need some help.
I'm sure we all know this case when you create twenty scenes off of the same base scene, then realize there is a light missing, you forgot a background item or character etc. Simple to fix by creating a subset of the items you want to add - and literal hell to manually go through opening 20 files, merging the same subsets twenty times, then saving them and re-rendering them.
In theory, this sounds relatively simple, and I even think I have most of it down by copy-pasting a lot of code from various forum threads together. But I am a complete noob with Daz Scripts (though full-time dev in my day job), and I can't seem to find proper tutorials or documentation, no matter how hard I look. No idea how you guys learned Daz Script in the first place :S
Here is what I have so far:
(function () {
// How can I load both scene and subset lists via file dialog?
var aScenesToAddTo = ["D://testfiles/1.duf", "D://testfiles/2.duf"]
var aSceneSubsetsToAdd = ["D://testfiles/subsets/1.duf", "D://testfiles/subsets/2.duf"]
var oAssetIOMgr = App.getAssetIOMgr();
for (var i = 0; i < aScenesToAddTo.length; i++) {
var sScenePath = aScenesToAddTo[i]
var sPathSplits = sScenePath.split("/")
var sSceneName = sPathSplits[sPathSplits.length - 1]
print(sSceneName)
var oResult = oAssetIOMgr.doLoad(sScenePath)
if (oResult.valueOf() != 0) {
print('Couldnt load original scene ',sSceneName,'. error message: ', oResult.valueOf(), getErrorMessage(oResult))
}
else{
for (var i = 0; i < aSceneSubsetsToAdd.length; i++) {
print("loading subset: ", aSceneSubsetsToAdd[i])
// how can I load/merge scene subsets?
}
// how can I quietly save the file in its original location without save dialog?
oSettings.setBoolValue("CompressOutput",false);
oSettings.setBoolValue("RunSilent",true);
//how to save over the current file?:
oAssetIOMgr.doSaveWithOptions(oAssetIOFilter,oSettings,true,"g:/frame000"); // No ".duf" in the file path }
} print("My job here is done!")
})();
Thanks in advance for any help you can give!
Comments
Using DzFileInfo will make it easier to split the filename.
DzAssetIOMgr.doLoad has the option to set name and load method, where you would want MergeFile http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/assetiomgr_dz#a_1a1a9ab1b19d85443a1832c46235f929f0 - though the default without a specification should, I think, merge, since that is the default behaviour for subsets.