Save scene without file dialog

msorrelsmsorrels Posts: 44
edited December 1969 in Daz SDK Developer Discussion

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

  • Richard HaseltineRichard Haseltine Posts: 100,886
    edited December 1969

    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.

  • msorrelsmsorrels Posts: 44
    edited December 1969

    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.

  • Richard HaseltineRichard Haseltine Posts: 100,886
    edited December 1969

    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.

  • msorrelsmsorrels Posts: 44
    edited December 1969

    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.

  • v-manv-man Posts: 0
    edited December 1969

    msorrels said:
    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.

Sign In or Register to comment.