I'm searching some improvement on that script. Sometimes you need to replace simple object by another as an instanced one, This script was designed for that and it was usefull since many years, but now as I've didn't take care about the scale attribute, it didn't work with obect with different scale.
Now i need to get the scale value on the result.
Select one or more object that were not instanced from any object and at last, select the object you want to instance at there position.
string $selObjs = `ls -sl` ; // all of the selected
int $count = `size($selObjs)` ; // how many selected?
int $second2last = $count-1 ;
string $dup = $selObjs[$second2last] ; // last selected
float $pos , $rot ;
int $i ;
string $instanz ;
string $tmp ;
// for every item in the selection list DO:
for ( $i = 0 ; $i < $second2last ; $i++ )
clear $pos ; clear $rot ; // make sure no old values are still stored here
$tmp = `duplicate -ilf $dup` ; // duplicate the last object 1 time
$instanz = $tmp ; // trick; duplicate returns an array, but we only need the very 1st one
$pos = `xform -q -ws -t $selObjs[$i]` ; // get the position of the item to clone
$rot = `xform -q -ws -ro $selObjs[$i]` ; // get the rotation as well
xform -ws -t $pos $pos $pos $instanz ; // set the instance to that position
xform -ws -ro $rot $rot $rot $instanz ; // set the rotation as well
delete $selObjs[$i] ; // delete the 'wrong' object
This script was ok for return good position and rotation from the target an get good result. But I need feature in order get the scale attribute back. At this time if i create multiple object at different location, with different rotation and scale, i can't get back the scale on the result.
Replacing the -ro or -t by -s ,-sca or -scale didn't work at all. how can i fix that feature ?