Using a companion script to perform additional tasks on Poser format content.

Author: Rob Whisenant, © 2008


I don't recall which version made this functionality public, but at the time of this writing DAZ Studio supports the ability to use a script to provide functionality not provided by import alone. The specifics of how to make use of this functionality in your own work is what I'll describe below.

The first thing to know is that the script must be named identically to the Poser format file it provides the additional functionality for. The exception of course being the file extension; the script can be one of ascii (.ds), binary or binary encrypted (.dsb) formats.

The second thing to know is that by placing the script next to the Poser format file you are effectively telling the Content Manager (DzContentMgr) to execute the script instead of importing the file that the user thought they were loading. What this means is… if the intent is to provide additional functionality (and not replace), the script will need to handle importing the invoking file…

Below is an example that shows how to accomplish this…

// Get the arguments passed in to the script
var aARGS = getArguments();
// If we've got atleast one
if( aARGS.length >= 1 )
{
	// Print the arguments to the IDE console/log
	print( String( "Arguments:\n\t%1" ).arg( aARGS.join( "\n\t" ) ) );
 
	// Get the import manager
	var oIMPORT_MANAGER = App.getImportMgr();
	// Import the file
	oIMPORT_MANAGER.readFile( aARGS[ 0 ] );
}
else{ print( "Arguments: NONE" ); }

The example above is intentionally very simple. When the Content Manager executes the script it passes in a single argument; the absolute path of the file that invoked its execution. Passing this value to the Import Manager loads the file in the same way that a file which doesn't have an associated script does.

What can be done before or after importing the file is only limited by your imagination and your understanding of the DAZ Studio API.