Digital Art Zone

 
     
Save pose and shape presets, and load them back.
Posted: 15 September 2012 07:34 AM   [ Ignore ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27

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

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 15 September 2012 11:59 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13606
Joined  2003-10-09

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?

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 15 September 2012 12:29 PM   [ Ignore ]   [ # 2 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27
Richard Haseltine - 15 September 2012 11:59 AM

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

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 15 September 2012 03:52 PM   [ Ignore ]   [ # 3 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27

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?

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 16 September 2012 10:25 AM   [ Ignore ]   [ # 4 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27

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

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 17 September 2012 04:49 PM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRank
Total Posts:  312
Joined  2003-10-09

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

 Signature 

- Documentation Center
- Install Manager
- DAZ Studio 4.x
- DSON Importer
- DSON File Format Specification

Profile
 
 
Posted: 17 September 2012 05:12 PM   [ Ignore ]   [ # 6 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27
rbtwhiz - 17 September 2012 04:49 PM

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.

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile