Below is an example demonstrating how to adjust the origin of selected nodes in the scene to be the center of their respective bounding boxes, via script.
// 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; }; /*********************************************************************/ // Define common message variables var sTitle = text( "Selection Error" ); var sMessage = text( "You must select one or more nodes to perform this action." ); var sButton = text( "&OK" ); // Get the selected nodes var aNodes = Scene.getSelectedNodeList(); // Get the number of nodes var nNodes = aNodes.length; // If we do not have nodes if( nNodes < 1 ){ // Alert the user MessageBox.warning( sMessage, sTitle, sButton, "" ); // We are done... return; } // Declare working variables var oNode; var boxBounding; var nMidY; var vecCenter; // Start collecting events for the undo stack beginUndo(); // Iterate over the nodes for( var i = 0; i < nNodes; i += 1 ){ // Get the 'current' node oNode = aNodes[ i ]; // Get the local bounding box for the node boxBounding = oNode.getLocalBoundingBox(); // Calculate the center of the bounding box nMidY = (boxBounding.maxY - boxBounding.minY) * 0.5; // Create a translation vector vecCenter = new DzVec3( 0, nMidY, 0 ); // Set the origin for the node; as default oNode.setOrigin( vecCenter, true ); // Adjust to account for controllers oNode.adjustOrigin( vecCenter ); } // Push the events to the undo stack; as a single event acceptUndo( text( "Center Origin(s)" ) ); // Finalize the function and invoke })();