User Tools

Site Tools


Importer Settings

Summary

Below is an example demonstrating how you can iterate over all importers and inspect them for any script accessible settings. These settings can then be used to control the importer via script.

API Areas of Interest

Example

Importer_Settings.dsa
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){
 
	// Get the import manager
	var oImportMgr = App.getImportMgr();
	// Get the number of importers
	var nImporters = oImportMgr.getNumImporters();
 
	// Declare working variables
	var oImporter, oSettings;
	var aExtensions;
	var nExtensions;
 
	// Iterate over all importers
	for( var i = 0; i < nImporters; i += 1 ){
		// Get the 'current' importer
		oImporter = oImportMgr.getImporter( i );
		// Create a new settings object to collect settings with
		oSettings = new DzFileIOSettings();
		// Cause the importer to give up the goods,
		// without displaying its options dialog
		oImporter.getOptions( oSettings, false, "" );
		// Dump information about the exporter to the console/log,
		// so we can see what we are dealing with
		print( "-----------------------------" );
		print( "Class Name :", oImporter.className() );
		print( "Description :", oImporter.getDescription() );
		// Get the number of extensions supported by the importer
		nExtensions = oImporter.getNumExtensions();
		// Pre-size the extensions array for each importer
		aExtensions = new Array( nExtensions );
		// Iterate over the extensions, setting each element in the array
		for( var j = 0; j < nExtensions; j += 1 ){
			aExtensions[ j ] = oImporter.getExtension( j );
		}
		print( "Extension :", aExtensions.join( ", " ) );
		print( "Settings :", oSettings.toJsonString() );
		print( "\n" );
	}
 
// Finalize the function and invoke
})();