Reset scale to bounding box scale.

Reset scale to bounding box scale.

darioOrtisi
Collaborator Collaborator
1,094 Views
2 Replies
Message 1 of 3

Reset scale to bounding box scale.

darioOrtisi
Collaborator
Collaborator

Hi guys.

I need an urgent help. I have a lot of objects and i need to reset the scale, that is to 1-1-1, to the bounding box dimensions.

So if i have a cube and scale it and freeze transformation, i get scale to 1-1-1. So i want that the scale reset to original based to BBox.

Anyone can helps me? 

Thanks

0 Likes
Accepted solutions (1)
1,095 Views
2 Replies
Replies (2)
Message 2 of 3

brentmc
Autodesk
Autodesk
Accepted solution

Hi,

 

The easiest way to do this is using a Mel script and you could tweak it to suit your needs.

For example, if you want the final scale to be uniform then you could use the min/max/average of the bounding box dimensions etc.

// For each selected object
for ($obj in `ls -sl`) {
    // Get the bounding box and calculate the scaling
    float $box[] = `xform -q -boundingBox $obj`;
    float $scl[] = { $box[3]-$box[0], $box[4]-$box[1], $box[5]-$box[2] };
    
    // Apply inverse scale
    xform -scale (1.0/$scl[0]) (1.0/$scl[1]) (1.0/$scl[2]) $obj;
    
    // Freeze scaling
    makeIdentity -apply 1 -scale 1 $obj;
    
    // Restore original scaling
    xform -scale $scl[0] $scl[1] $scl[2] $obj;
}

 

Brent McPherson
Principle Engineer
Message 3 of 3

darioOrtisi
Collaborator
Collaborator

Hi @brentmc 

It works, thank you very much. You saved me.

0 Likes