Below is an example demonstrating how you can remotely execute the Figure Metrics script, included as part of the Measure Metrics product, by passing in a settings object to control the operation of the script without displaying its dialog.
// DAZ Studio version 4.6.2.118 filetype DAZ Script // Define an anonymous function; // serves as our main loop, // limits the scope of variables (function(){ /*********************************************************************/ // String : A function for retrieving a translation if one exists function text( sText ) { // If the version of the application supports qsTr() if( typeof( qsTr ) != "undefined" ){ // Return the translated (if any) text return qsTr( sText ); } // Return the original text return sText; }; /*********************************************************************/ // void : A function to run the Figure Metrics script silently function runSilent( oSettings ){ // If the version number is older than 4.6.2.118 if( App.version < 0x04060276 ){ // Inform the user MessageBox.information( text( "This script requires %1 4.6.2.118 or newer. Update and try again." ) .arg( App.appName ), text( "Version Error" ), text( "&OK" ) ); // We can't pass in arguments to a script; we are done... return; } // Define the relative path to the Figure Metrics script var sRelPath = "/Scripts/Utilities/Figure Metrics.dse"; // Get the content manager var oContentMgr = App.getContentMgr(); // Attempt to find the script, in native directories var sFullPath = oContentMgr.findFile( sRelPath, DzContentMgr.NativeDirs ); // If we can't find the script if( sFullPath.isEmpty() ){ // Inform the user MessageBox.information( text( "Unable to locate the '%1' script. Check mapped native content directories and try again." ).arg( sRelPath ), text( "Resource Error" ), text( "&OK" ) ); // We are done... return; } // Create a script object var oScript = new DzScript(); // If the script doesn't load if( !oScript.loadFromFile( sFullPath ) ){ // Inform the user MessageBox.information( text( "An error occured while loading the '%1' script." ).arg( sFullPath ), text( "Read Error" ), text( "&OK" ) ); // We are done... return; } // Execute the script; pass in an array of the argument oScript.execute([ oSettings ]); } /*********************************************************************/ // Run the Figure Metrics script silently runSilent( { "configuration": "Genesis2Female", "measurements": "5 ft 8 in, 36-24-36", //"tolerance": 0.0001, //"maxIterations": 200, //"save": "Characters/Figure Metrics/G2F Hourglass" } ); // Finalize the function and invoke })();
The Figure Metrics script takes exactly 1 argument; an Object with no less than two (2), and up to five (5), named members that are used to control its operation. The configurable settings handled by the Figure Metrics script are as follows:
var sPresetPath = String("%1/resources/Figure Metrics/Presets/Configurations/%2") .arg( App.getAppDataPath() ).arg( oSkeleton.name );
{ "Genesis2Female": { "Height": { "Node": "Genesis2Female", "Property": "Scale" }, "BustChestCircumference": { "Node": "Genesis2Female", "Property": "CTRLBustCircumference" }, "WaistCircumference": { "Node": "Genesis2Female", "Property": "PBMWaistCircumference" }, "LowHipCircumference": { "Node": "Genesis2Female", "Property": "PBMLowHipCircumference" } } }
var sPresetPath = String("%1/resources/Figure Metrics/Presets/Measurements/%2") .arg( App.getAppDataPath() ).arg( oSkeleton.name );
{ "Genesis2Female": { "Height": [ 68, "in" ], "HeadCircumference": [ 22.33, "in" ], "BustChestCircumference": [ 36, "in" ], "WaistCircumference": [ 24, "in" ], "LowHipCircumference": [ 36, "in" ] } }