Trying to write a simple script - You select an object, and running the script queries for the object's bounding box dimensions. It then creates a polycube with the same dimensions, and positions it EXACTLY where the object's bounding box is.
So far, I've run into issues with objects with multiple levels of transform, and am not sure of the solution. Don't know if it has to do with pivots, etc.
My progress so far:
The key line is where I try to parent the new cube relatively to the transform of the selected object. I thought this would do it - what am I missing?
CODE
$nodes = ls -selection;
for( $node in $nodes ){
makeBounding( $node );
};
//Make a polygonal cube identical to object's bounding box
global proc string makeBounding(string $obj){
float $minx,$maxx,$miny,$maxy,$minz,$maxz;
$minx = getAttr ($obj + ".boundingBoxMinX");
$maxx = getAttr ($obj + ".boundingBoxMaxX");
$miny = getAttr ($obj + ".boundingBoxMinY");
$maxy = getAttr ($obj + ".boundingBoxMaxY");
$minz = getAttr ($obj + ".boundingBoxMinZ");
$maxz = getAttr ($obj + ".boundingBoxMaxZ");
$x = $maxx - $minx;
$y = $maxy - $miny;
$z = $maxz - $minz;
$boundingCube = polyCube -w $x -h $y -d $z -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;
parent -r $boundingCube[0] $obj;
return $boundingCube[0];
}
mfrederickson