Save pose and shape presets, and load them back.

Alessandro_AMAlessandro_AM Posts: 1,553
edited September 2012 in Daz SDK Developer Discussion

Any chance to have an example of how to use the SDK to save a figure pose (and shape) preset to .duf and load it back? Thanks

Post edited by Alessandro_AM on

Comments

  • Richard HaseltineRichard Haseltine Posts: 19,963
    edited December 1969

    You mean trigger the saving of one of the standard types, or create your own subset of DSON for your own purposes? or even a completely new range of properties not covered by the current standard?

  • Alessandro_AMAlessandro_AM Posts: 1,553
    edited September 2012

    You mean trigger the saving of one of the standard types, or create your own subset of DSON for your own purposes? or even a completely new range of properties not covered by the current standard?

    Hi Richard, say for example that you pose Genesis, apply some shaping, and you want to save that information so that you can load it back later. I suppose one should save a pose preset .duf and a shape preset .duf file?

    EDIT: in practice I'd like to replicate what you can do within Studio from the File->Save as->Pose Preset and File->Save as->Shape Preset

    Post edited by Alessandro_AM on
  • Alessandro_AMAlessandro_AM Posts: 1,553
    edited September 2012

    I think I've located the proper class, DzAssetIOMgr.

    The following code can be used to save a pose preset:

    DzAssetIOMgr *myAssetMgr;
    QString path="/temp/test.duf";
    myAssetMgr->doSave(10,path); // 10 is the filter ID related to the pose asset

    The only thing is that this procedure always prompts the user asking for a file to save to, and the options to set. Any chance to have it running "silently"? I.e. without showing any dialog?

    Post edited by Alessandro_AM on
  • Alessandro_AMAlessandro_AM Posts: 1,553
    edited September 2012

    I recall I did something similar long time ago, and so I created a new asset filter, and edited the associated settings:

    DzAssetIOFilter *myFilter=myAssetMgr->getFilter(10); //10 indicates it's a pose preset
    DzFileIOSettings *mySettings = new DzFileIOSettings();
    myFilter->getDefaultOptions(mySettings); // get option settings for this filter
    mySettings->setStringValue("RootLabel", "Genesis"); // set the object name
    mySettings->setIntValue( "RunSilent", 1 ); // set to 1 to skip import dialog
    myFilter->doSave(mySettings,"/myPosePreset.duf");

    Now, if I use it with "RunSilent"=0, the save dialog will prompt asking where to save the file, options etc., and obviously it will create the file.

    With "RunSilent=1" the routine will run but no file will be created, and the doSave function returns a "DZ_OPERATION_FAILED_ERROR 0x00000062".

    Any DAZ folks around here could tell me what's missing? Thanks

    Post edited by Alessandro_AM on
  • rbtwhizrbtwhiz Posts: 485
    edited December 1969

    Safe to assume this post (and those following) answers your question? Porting from script should be pretty straight forward... (as you mention here).

    I'll likely post some updates to the samples later tonight, which will reflect the recent change here to use DzAssetIOMgr::doSaveWithOptions() instead of DzAssetIOFilter::doSave() directly.

    -Rob

  • Alessandro_AMAlessandro_AM Posts: 1,553
    edited December 1969

    rbtwhiz said:
    Safe to assume this post (and those following) answers your question? Porting from script should be pretty straight forward... (as you mention here).

    I'll likely post some updates to the samples later tonight, which will reflect the recent change here to use DzAssetIOMgr::doSaveWithOptions() instead of DzAssetIOFilter::doSave() directly.

    -Rob

    Yes Rob, that post was satisfactory and answered all my questions. Thanks again.

Sign In or Register to comment.
Rocket Fuel