Pages

Sunday, December 20, 2009

Translated Bounding Box 2


I recently wrote script named Translated Bounding Box which works fine on 3ds Max 2008 and higher. It's based on nodeGetBoundingBox() function (new in 3ds Max 2008). The function also available for previous Max versions through AVG (Avguard Extensions), but Dave ask me how to do this without AVG in 3ds max 9, so I wrote this cheat procedure snippet code. Maybe is not the best solution but I hope this help :)
for i in selection do (
c = snapshot i
c.transform = matrix3 1
d = dummy boxsize:(c.max - c.min)
delete c
d.transform = i.transform
d.pos = i.center
)

I think the "trick" is clear. I create a temp copy and reset it transform to can assign correct size to the dummy, and finaly align dummy to the original object. Well, maybe is good to optimize the code by turns undo off for temp object :)
for i in selection do (
local c
with undo off ( c = snapshot i )
c.transform = matrix3 1
d = dummy boxsize:(c.max - c.min)
with undo off ( delete c )
d.transform = i.transform
d.pos = i.center
)

P.S. -- Ultimately I decided to update the script and upload new version (0.2) at ScriptSpot.

2 comments:

Thanks for your comment