Save scene without file dialog
msorrels
Posts: 44
So I'm trying to save the current scene without a file browse dialog coming up (I'm doing it in C++ but for this I can show the code with DAZ Script). There are lots of references to this problem all over the place but actual working code appears to be elusive.
The best I've been able to do is this:
var oSaveFilterMgr = App.getAssetIOMgr();
var nSaveFilter = oSaveFilterMgr.findFilter( "DzSceneAssetFilter" );
var oSaveFilter = oSaveFilterMgr.getFilter( nSaveFilter );
if( oSaveFilter ){
var oSettings = new DzFileIOSettings();
oSaveFilter.getDefaultOptions( oSettings );
oSettings.setBoolValue("RunSilent", true);
oSaveFilterMgr.doSaveWithOptions(oSaveFilter, oSettings, false, "d:/test.duf");
}
Is this the best/only way to save the current scene without having a save dialog open up? I think it's kind of strange I had to pull constants like "DzSceneAssetFilter" and "RunSilent" out of thin air like that. I had DS dump the settings so I could see them but still none of these are documented at all. Will this work in the future? Does this really work now?
Comments
If you enter your name (or a name, it doesn't have to be real) in the author information in Edit>Preferences then any scene saved by you, with the name included, will save without prompting. It's a feature to avoid overwriting library files accidentally.
I have author set -- that's another/different issue.
My problem is doSave (and it's variants) always brings up the Window's file save-as dialog, rather than just save straight to the file. In order to suppress this I ended up having to set the RunSilent setting to true. But it's totally undocumented.
Ah, I see (and am surprised). It may be worth looking through the scripting forum (Developer Discussions), probably on the old forum - I'm pretty sure Rob did take part in an extended discussion of the save logic there, which may be at least somewhat applicable.
And the second question. How do I get the current scene filename?
Scene.getFilename()
Doesn't work. It will return the default/new scene filename. But it changes to an empty string when you load or save the scene. I've poked around a bunch of the objects related to saving/loading but haven't been able to work out how to get the current scene's save filename.
Not sure about the filename but I was asking similar questions about saving a scene on this thread :
http://www.daz3d.com/forums/discussion/26641/
At the bottom of the thread you can see the response by rbtwhiz for the explanation of DzAssetIOMgr::doSaveWithOptions
Hope that helps some.