If you want a shorter version of this I wrote this procedure:
global proc float[] GetMultipleBB(string $sel[]){
float $bb[];
// go through selection
for($i=0; $i<size($sel); $i++){
float $thisBB[] = xform -q -ws -bb $sel[$i]
;
// First check if bb[] is null, if so, just set the values
if(size($bb) == 0){
$bb = $thisBB;
}
else{
if($thisBB[0] < $bb[0]) $bb[0] = $thisBB[0];
if($thisBB[1] < $bb[1]) $bb[1] = $thisBB[1];
if($thisBB[2] < $bb[2]) $bb[2] = $thisBB[2];
if($thisBB[3] > $bb[3]) $bb[3] = $thisBB[3];
if($thisBB[4] > $bb[4]) $bb[4] = $thisBB[4];
if($thisBB[5] > $bb[5]) $bb[5] = $thisBB[5];
}
}
return $bb;
[b]}
[/b]Just pass in an object selction like this:
string $sel[] = ls -sl -fl
;
float $selBB[] = GetMultipleBB($sel);
Also if you would like to find the center of all the selected objects I wrote this procedure as well:
global proc vector GetBBCenter(float $bb[]){
vector $center;
float $x = ($bb[0] + $bb[3]) / 2;
float $y = ($bb[1] + $bb[4]) / 2;
float $z = ($bb[2] + $bb[5]) / 2;
$center = <>;
return $center;
[b]}
[/b]Just pass in the float array you recieved from GetMultipleBB() like so:
string $sel[] = ls -sl -fl
;
float $selBB[] = GetMultipleBB($sel);
vector $center = GetBBCenter($selBB);