/********************************************************************** 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/callback_rendermgr_active_renderer_changed_property_current_value_changed/start // Define an anonymous function; // limits the scope of variables (function(){ // 'CallBack' is a global transient variable, available when // this script is executed by a DzCallBack // If we did not find the 'CallBack' global transient; // this script was executed outside the context of a DzCallBack if( typeof( CallBack ) == "undefined" ){ // We are done... return; } // Get the object that prompted the callback var oSender = CallBack.getSender(); // If we do not have a sender or the sender is not the render manager if( !oSender || !oSender.inherits( "DzRenderMgr" ) ){ // We are done... return; } // oScript, sBasePath, and sProperty are assumed to be defined in the script // that includes this script; i.e., the CallBack // created in Callbacks_Element_Post_Load_Create.ds* // Get the path of the FindProperty script. Doing it this way, we can debug // with an ascii file and ship a binary [encrypted] file with the same // name... without having to update the contents of the script or manually // handle the file extensions. var sFindPropertyPath = oScript.getScriptFile( "%1/FindProperty".arg( sBasePath ) ); // If the script was not found if( sFindPropertyPath.isEmpty() ){ // We are done... return; } // Include the FindProperty script include( sFindPropertyPath ); /*********************************************************************/ // Get the number of arguments var nArgs = CallBack.getArgCount(); // If we did not get arguments if( nArgs < 1 ){ // We are done... return; } // Get the first argument var oArg = CallBack.getArg( 0 ); // If the argument is not a renderer if( !oArg.inherits( "DzRenderer" ) ){ // We are done... return; } // If the element was not found if( !oElement ){ // We are done... return; } // Find the property var oProperty = findElementProperty( oElement, sProperty, false ); // If the property was not found if( !oProperty ){ // We are done... return; } // Emit the signal oProperty.currentValueChanged(); // Finalize the function and invoke })();