mcjSelectedGotoLastSelected
Purpose:
 Bring Multiple objects to the position of one object : the last selected object
Install:Â
Unzip the zip package found at the bottom of this page in your Daz Format Content Folder
ex: C:\Users\USERNAME\Documents\DAZ 3D\Studio\My Library
once you refresh your Content tab, the script will be found in /scripts/mCasual
History:
2023-03-03 13:33 - Initial release ( had a bug )
2023-03-03 13:57 - Fixed the bug in  the subDoit() function
Use:
Select all the objects you want to move, then your last selection must be the target object.Â
Run the script
[Yes Exactly] sends all objects to the position of the target object
[Yes With 10cm Offsets] sends them to the target object, with a Z offset of 10cm between each one.
The Code
//by mCasualJacques 2023-03-03
appName = "mcjSelectedGotoLastSelected";
if( Scene.getNumSelectedNodes() < 2 )
{
message(
"You must select 2 or more objects,<br>" +
"Then this script will send all the selected objects<br>" +
"to the position of the last selected object"
);
}
else
{
doit();
}
//==============================================================================
//
//==============================================================================
function doit()
{
var primName = ( Scene.getPrimarySelection().getLabel() );
var nodes = Scene.getSelectedNodeList();
var n = nodes.length - 1;
var clientNames = "";
for( var i = 0; i < n; i++ )
{
if( ( i%5 == 0 ) && ( i != 0 ) )
{
clientNames += "\n";
}
if( i > 0 )
{
clientNames += ", ";
}
clientNames += nodes[i].getLabel();
}
var iDoit = getChoice( primName, clientNames )
switch( iDoit )
{
case 0: // yes
subDoit( 0, nodes ); //0cm off
break;
case 1: // yes with offset
subDoit( 10, nodes ); //10cm off
break
case 2: //no way
break;
}
}
//==============================================================================
//
//==============================================================================
function message( str )
{
MessageBox.information( "Oops", str, "&OK" );
}
//==============================================================================
//
//==============================================================================
function getChoice( primName, clientNames )
{
var n = clientNames.length;
var question = (
"According to your selection all selected nodes\n" +
"will jump top the position of the node labeled\n" +
primName + "\n" +
"List of the nodes that will move:\n" +
clientNames.right( 320 )
);
var answer = MessageBox.question(
question,
appName,
"Yes Exactly",
"Yes with 10cm offset",
"No Way"
);
return( answer )
}
//==============================================================================
//
//==============================================================================
function subDoit( off, nodes )
{
beginUndo();
var n = nodes.length - 1;
var p = nodes[n].getWSPos();
var iniZ = p.z;
p.z = iniZ + ( i + 1 ) * off;
for( var i = 0; i < n; i++ )
{
p.z = iniZ + ( i + 1 ) * off;
nodes[i].setWSPos( p );
}
acceptUndo( appName );
}