silent saving doesnt save

Hi everyone,

I started a little scripting project and ran into a problem. The endgoal is to loop over the frames of the timeline in a scene and save each frame as a posePresetFile in a defined folder.

For this goal the first step would be to save a file without user interaction. I know this is a pretty old hat and i looked at the given example and found an older thread with close to this code:

// DAZ Studio version 4.12.0.86 filetype DAZ Scriptvar oAssetIOMgr = App.getAssetIOMgr();var nAssetIOFilter = oAssetIOMgr.findFilter( "DzPoseAssetFilter" );var oAssetIOFilter = oAssetIOMgr.getFilter( nAssetIOFilter );if( oAssetIOFilter ){	var oSettings = new DzFileIOSettings();	oAssetIOFilter.getDefaultOptions( oSettings );	//save only the current frame	oSettings.setBoolValue("SaveCurFrame",true);	oSettings.setBoolValue("CompressOutput",true);	oSettings.setBoolValue("RunSilent",true);	oAssetIOMgr.doSaveWithOptions(oAssetIOFilter,oSettings,true,"g:/frame000.duf");}

The problem is that the file flat out isnt saved. The output only says "Running silent. No "NodeNames" defined. (in case this show an obvious error that i dont get).

Have i gotten the path wrong? or am i on the completly wrong track in the first place. Thanks for any pointers ^^

Comments

  • Hi,

    The problem is that you forgot to select nodes to save.

    You should look to this complete example : http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/file_io/save_duf_pose/start

    A simple copy/paste of that code should give you exactly what you want (silent pose saving, selecting frame to export etc...). You'll just have to change the path of the saved file, line 467 :

    var sFile = "G:/frame000";

    Hope that helps!

  • Here's a short version to begin with :

    // function taken from http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/file_io/save_duf_pose/startfunction setElementPropertyOptions( oSettings, sElementSettingsKey, sElementName, aPropNames, bSubItems ) {    var oElementsSettings = oSettings.getSettingsValue( sElementSettingsKey );    if( !oElementsSettings ) oElementsSettings = oSettings.setSettingsValue( sElementSettingsKey );    var oElementSettings = oElementsSettings.getSettingsValue( sElementName );    if( !oElementSettings ) oElementSettings = oElementsSettings.setSettingsValue( sElementName );    var vPropertyItem, sPropertyName, oPropertySettings, oSubItemSettings;    for( var i = 0; i < aPropNames.length; i += 1 ){    	vPropertyItem = aPropNames[ i ];    	if( !bSubItems || typeof( vPropertyItem ) == "string" ){    		sPropertyName = vPropertyItem;			oElementSettings.setStringValue( String(i), sPropertyName );}		else if( typeof( vPropertyItem ) == "object" && Array.isArray( vPropertyItem ) ){    		sPropertyName = (vPropertyItem.length > 0 && typeof( vPropertyItem[ 0 ] ) == "string" ? vPropertyItem[ 0 ] : "");    		if(sPropertyName.isEmpty()) continue;			oPropertySettings = oElementSettings.getSettingsValue( i );    		if(!oPropertySettings) oPropertySettings = oElementSettings.setSettingsValue( i );			oPropertySettings.setStringValue( "name", sPropertyName );			oSubItemSettings = oPropertySettings.getSettingsValue( "subitems" );    		if(!oSubItemSettings) oSubItemSettings = oPropertySettings.setSettingsValue( "subitems" );    		for( var j = 1; j < vPropertyItem.length; j += 1 ) oSubItemSettings.setStringValue( String( j - 1 ), vPropertyItem[ j ])}}};function setCommonNodePropertyOptions( oSettings, aNodeNames, aPropNames ) {    for( var i = 0; i < aNodeNames.length; i += 1 ) setElementPropertyOptions( oSettings, "NodeNames", aNodeNames[ i ], aPropNames, false );}var oAssetIOMgr = App.getAssetIOMgr();var nAssetIOFilter = oAssetIOMgr.findFilter( "DzPoseAssetFilter" );var oAssetIOFilter = oAssetIOMgr.getFilter( nAssetIOFilter );var oSettings = new DzFileIOSettings();oAssetIOFilter.getDefaultOptions( oSettings );var aNodeNames = ["hip"]; // Put here all bones you want to save in your pose file, or create a recursive function to list themsetCommonNodePropertyOptions( oSettings, aNodeNames, [ "XRotate", "YRotate", "ZRotate" ] ); //Specify here all bones parameters you want to save. Add "XTranslate", "YTranslate", "ZTranslate" if needed.oSettings.setBoolValue("SaveCurFrame",true);oSettings.setBoolValue("CompressOutput",false);oSettings.setBoolValue("RunSilent",true);oAssetIOMgr.doSaveWithOptions(oAssetIOFilter,oSettings,true,"g:/frame000"); // No ".duf" in the file path

     

    That one saves only the "hip" bone's rotations. Adapt it to your needs!

Sign In or Register to comment.