Below are examples demonstrating how to set the active DAZ Studio Formats path, Poser Formats path, Other Import Formats path, Products container, or Categories container in the Content Library pane via script.
// Define an anonymous function; // serves as our main loop, // limits the scope of variables (function( sPath ){ /*********************************************************************/ // 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; }; /*********************************************************************/ // Get the pane manager var oPaneMgr = MainWindow.getPaneMgr(); // If the pane manager was not found if( !oPaneMgr ){ // We are done... return; } // Find the content library pane var oPane = oPaneMgr.findPane( "DzContentLibraryPane" ); // If the pane was not found if( !oPane ){ // We are done... return; } // If the app version is 4.8.1.51 or newer if( App.version64 >= 0x0004000800010033 ){ // Browse to the path oPane.browseToNativeFolder( sPath ); // Otherwise } else { // Attempt to fall back try { // Get the asset manager var oAssetMgr = App.getAssetMgr(); // Get the content manager var oContentMgr = App.getContentMgr(); // Set the base to the first mapped native formats directory var sBase = oContentMgr.getContentDirectoryPath( 0 ); // Set the first value to the id of the top-level container, // set the second value to the base path within that container var aIdPath = [ oAssetMgr.getStudioDirID(), sBase ]; // Split the relative path into its individual parts var aRelativeParts = sPath.split( "/" ); // Iterate over each part in the relative path, for( var i = 0; i < aRelativeParts.length; i += 1 ){ // Push the full path of the 'current' part onto the id path array aIdPath.push( String("%1/%2") .arg( sBase ) .arg( aRelativeParts.slice(0, i + 1).join( "/" ) ) ); } // Cause the 'current' container to change oPane.browseToIDPath( aIdPath ); // Cause the 'current' container to update oPane.updateContainer( aIdPath ); // Handle errors } catch( e ){ // Define the strings used to provide feedback var sTitle = text( "Resource Error" ); var sMessage = text( "A newer version of %1 is required " + "to execute this script.").arg( App.appName ); var sAccept = text( "&OK" ); // Provide feedback to the user MessageBox.critical( sMessage, sTitle, sAccept ); // We are done... return; } } // Finalize the function and invoke })( "People/Genesis 3 Female" );
// Define an anonymous function; // serves as our main loop, // limits the scope of variables (function( sPath ){ /*********************************************************************/ // 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; }; /*********************************************************************/ // Get the pane manager var oPaneMgr = MainWindow.getPaneMgr(); // If the pane manager was not found if( !oPaneMgr ){ // We are done... return; } // Find the content library pane var oPane = oPaneMgr.findPane( "DzContentLibraryPane" ); // If the pane was not found if( !oPane ){ // We are done... return; } // The intermedate portion of a Poser path var sIntermediate = "Runtime/Libraries"; // If the app version is 4.8.1.51 or newer if( App.version64 >= 0x0004000800010033 ){ // Browse to the path oPane.browseToPoserFolder( String("%1/%2").arg( sIntermediate ).arg( sPath ) ); // Otherwise } else { // Attempt to fall back try { // Get the asset manager var oAssetMgr = App.getAssetMgr(); // Get the content manager var oContentMgr = App.getContentMgr(); // Set the base to the first mapped Poser formats directory var sBase = String("%1/%2") .arg( oContentMgr.getPoserDirectoryPath( 0 ) ) .arg( sIntermediate ); // Set the first value to the id of the top-level container, // set the second value to the base path within that container var aIdPath = [ oAssetMgr.getPoserDirID(), sBase ]; // Split the relative path into its individual parts var aRelativeParts = sPath.split( "/" ); // Iterate over each part in the relative path, for( var i = 0; i < aRelativeParts.length; i += 1 ){ // Push the full path of the 'current' part onto the id path array aIdPath.push( String("%1/%2") .arg( sBase ) .arg( aRelativeParts.slice(0, i + 1).join( "/" ) ) ); } // Cause the 'current' container to change oPane.browseToIDPath( aIdPath ); // Cause the 'current' container to update oPane.updateContainer( aIdPath ); // Handle errors } catch( e ){ // Define the strings used to provide feedback var sTitle = text( "Resource Error" ); var sMessage = text( "A newer version of %1 is required " + "to execute this script.").arg( App.appName ); var sAccept = text( "&OK" ); // Provide feedback to the user MessageBox.critical( sMessage, sTitle, sAccept ); // We are done... return; } } // Finalize the function and invoke })( "Character/DAZ People" );
// Define an anonymous function; // serves as our main loop, // limits the scope of variables (function( sPath ){ /*********************************************************************/ // 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; }; /*********************************************************************/ // Get the pane manager var oPaneMgr = MainWindow.getPaneMgr(); // If the pane manager was not found if( !oPaneMgr ){ // We are done... return; } // Find the content library pane var oPane = oPaneMgr.findPane( "DzContentLibraryPane" ); // If the pane was not found if( !oPane ){ // We are done... return; } // If the app version is 4.8.1.51 or newer if( App.version64 >= 0x0004000800010033 ){ // Browse to the path oPane.browseToImportFolder( sPath ); // Otherwise } else { // Attempt to fall back try { // Get the asset manager var oAssetMgr = App.getAssetMgr(); // Get the content manager var oContentMgr = App.getContentMgr(); // Set the base to the first mapped other import formats directory var sBase = oContentMgr.getImportDirectoryPath( 0 ); // Set the first value to the id of the top-level container, // set the second value to the base path within that container var aIdPath = [ oAssetMgr.getImportDirID(), sBase ]; // Split the relative path into its individual parts var aRelativeParts = sPath.split( "/" ); // Iterate over each part in the relative path, for( var i = 0; i < aRelativeParts.length; i += 1 ){ // Push the full path of the 'current' part onto the id path array aIdPath.push( String("%1/%2") .arg( sBase ) .arg( aRelativeParts.slice(0, i + 1).join( "/" ) ) ); } // Cause the 'current' container to change oPane.browseToIDPath( aIdPath ); // Cause the 'current' container to update oPane.updateContainer( aIdPath ); // Handle errors } catch( e ){ // Define the strings used to provide feedback var sTitle = text( "Resource Error" ); var sMessage = text( "A newer version of %1 is required " + "to execute this script.").arg( App.appName ); var sAccept = text( "&OK" ); // Provide feedback to the user MessageBox.critical( sMessage, sTitle, sAccept ); // We are done... return; } } // Finalize the function and invoke })( "Folder/SubFolder/SubSubFolder" );
// Define an anonymous function; // serves as our main loop, // limits the scope of variables (function( sProductName, sGuid ){ /*********************************************************************/ // 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; }; /*********************************************************************/ // Get the pane manager var oPaneMgr = MainWindow.getPaneMgr(); // If the pane manager was not found if( !oPaneMgr ){ // We are done... return; } // Find the content library pane var oPane = oPaneMgr.findPane( "DzContentLibraryPane" ); // If the pane was not found if( !oPane ){ // We are done... return; } // If the app version is 4.8.1.51 or newer if( App.version64 >= 0x0004000800010033 ){ // Browse to the category oPane.browseToProduct( sProductName ); // Otherwise } else { // Attempt to fall back try { // Set the intermediate to the first character of the product name var sFirst = sProductName.substring( 0, 1 ); // Define the list of first words to skip var aSkip = [ "The", "A", "An" ]; // Split the product name into words var aWords = sProductName.split( " " ); // If there are multiple words and the first one is in the list if( aWords.length > 1 && aSkip.indexOf( aWords[ 0 ] ) > -1 ){ // Set the intermediate to the first character of second word sFirst = aWords[ 1 ].substring( 0, 1 ); } // Get the asset manager var oAssetMgr = App.getAssetMgr(); // Set the first value to the id of the top-level container, // set the second value to the first character of the product name, // set the third value to the product GUID var aIdPath = [ oAssetMgr.getProductsID(), sFirst, sGuid ]; // Cause the 'current' container to change oPane.browseToIDPath( aIdPath ); // Cause the 'current' container to update oPane.updateContainer( aIdPath ); // Handle errors } catch( e ){ // Define the strings used to provide feedback var sTitle = text( "Resource Error" ); var sMessage = text( "A newer version of %1 is required " + "to execute this script.").arg( App.appName ); var sAccept = text( "&OK" ); // Provide feedback to the user MessageBox.critical( sMessage, sTitle, sAccept ); // We are done... return; } } // Finalize the function and invoke })( "Genesis 3 Starter Essentials", "37c74e14-a461-4850-b03a-be7153806f6e" ); //"The Girl 7", "d4073ebf-4915-48dc-ad9d-802f34cad36a"
// Define an anonymous function; // serves as our main loop, // limits the scope of variables (function( sCategoryPath ){ /*********************************************************************/ // 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; }; /*********************************************************************/ // Get the pane manager var oPaneMgr = MainWindow.getPaneMgr(); // If the pane manager was not found if( !oPaneMgr ){ // We are done... return; } // Find the content library pane var oPane = oPaneMgr.findPane( "DzContentLibraryPane" ); // If the pane was not found if( !oPane ){ // We are done... return; } // If the app version is 4.8.1.51 or newer if( App.version64 >= 0x0004000800010033 ){ // Browse to the category oPane.browseToCategory( sCategoryPath ); // Otherwise } else { // Attempt to fall back try { // Create a new categories table var oDBCategory = new DzDBCategoriesTable(); // Get the category object for the desired relative path var oDBCategory = oDBCategory.findCategory( sCategoryPath ); // Initialize an ID path var sIdPtah = ""; // If we have a category if( oDBCategory ){ // Set the relative category index path sIdPtah = oDBCategory.getCategoryIDPath().join( "/" ); } // Split the category ID path into its parts var aIdPath = sIdPtah.split( "/" ); // Cause the 'current' container to change oPane.browseToIDPath( aIdPath ); // Cause the 'current' container to update oPane.updateContainer( aIdPath ); // Handle errors } catch( e ){ // Define the strings used to provide feedback var sTitle = text( "Resource Error" ); var sMessage = text( "A newer version of %1 is required " + "to execute this script.").arg( App.appName ); var sAccept = text( "&OK" ); // Provide feedback to the user MessageBox.critical( sMessage, sTitle, sAccept ); // We are done... return; } } // Finalize the function and invoke })( "Default/People/Real-World" );