/********************************************************************** This script is provided as part of the Daz Script Documentation. The contents of this script, and\or any portion thereof, may only be used in accordance with the following license: Creative Commons Attribution 3.0 Unported (CC BY 3.0) - http://creativecommons.org/licenses/by/3.0 To contact Daz 3D or for more information about Daz Script visit the Daz 3D website: - http://www.daz3d.com **********************************************************************/ // Source: /public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/elements/post_load_script_data_item_read/start // 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; }; /*********************************************************************/ // Declare working variables var sMessage; // Define common strings var sButton = text( "&OK" ); var sTitle = text( "Data Item Info" ); // 'DataItem' is a global transient variable, available when // this script is executed as a 'post load data item' // If we didn't find the 'DataItem' global transient; // this script was executed outside the context of a 'post load data item' if( typeof( DataItem ) == "undefined" ){ // Construct the message sMessage = "Oops... 'DataItem' doesn't exist."; // If we have the 'DataItem' global transient } else { // Get the owner of the data item var oElement = DataItem.getOwner(); // Define the lines of the message var aMessage = [ "Element Class: " + oElement.className(), "Element Name: " + oElement.getName(), "Data Class: " + DataItem.className(), "Data Name: " + DataItem.name ]; // If the data item is of the type we expect if( DataItem.inherits("DzSimpleElementScriptData") ){ // Get some extra info aMessage.push( "Data Script: " + DataItem.getScriptFilePath() ); } // Get the settings for the data item var oSettings = DataItem.getSettings(); // Get the value for the message key; default to something we know it won't be aMessage.push( "Data Settings: " + oSettings.toJsonString() ); // Convert the lines into a string sMessage = aMessage.join( "\n" ); } // Display the message MessageBox.information( sMessage, sTitle, sButton ); // Finalize the function and invoke })();