Load a .duf preset

How can you load a DUF file, such as a Posing, Shaping, or Materials preset via script?

I've attempted several things: 

  • Scene.loadScene(sFilename) - seems to attempt merging the file, but doesn't apply the presets (presumably it would work for a content-type DUF)
  • DzImportMgr.canImport(sFilename) - returns false for the specified pose preset DUF file (I used oFileInfo to test file existence beforehand)
  • DzScript.loadFromFile(sFilename) - DUF files aren't scripts, so this didn't work

Can someone clue me in?

Comments

  • DzContentMgr.openFile( sFilename , merge );

    You can get the Content Manager from

    App.getContentMgr();

    sFilename is the full path and file name, merge is true if you want to merge into the existing scene (presumably yes for a preset, in which case you don't need to explicitly set the value)  or load as a new scene. The return is true or false depending on success.

  • djigneodjigneo Posts: 283
    edited August 2015

    Confirmed success. Thanks, Richard!

    Basic proof of concept code for others wondering:

    var oContentMgr = App.getContentMgr();oContentMgr.openFile("C:\\DAZ 3D\\Studio\\My Library\\Presets\\Poses\\pose test.duf", true);

     

    Post edited by djigneo on
  • You can use / as the folder separator, which will save you from having to escape the \ character.

  • rbtwhizrbtwhiz Posts: 2,181

    Not just can, but is considered best practice.

    Qt uses "/" as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, Qt will translate your paths to conform to the underlying operating system.

    -Rob

  • djigneodjigneo Posts: 283

    Good to know, thanks for the tips!

  • mjc1016mjc1016 Posts: 15,001

    Windows is about the only thing on the planet that thinks '\' is still a good idea...

Sign In or Register to comment.