View Full Version : How do you find the size of an object?
03-22-2005, 11:07 AM
Is there a way to find the size of an objects bounding box in Max script?
I need to find the size of the box in local space rather than world space (I.e. the box is aligned to the axis of the object.)
I hoping thereís a simple solution to this. Iíve had a look around, but I canít find the answer. :hmm:
03-22-2005, 11:17 AM
EDIT: Bleh, read your post wrong. I need sleep... :banghead:
03-22-2005, 03:40 PM
EDIT: I should have tried first... My recommendation is in world space...
I think what you're looking for is the .max and .min properties... Those give you the bounding box corners thus "size = a.max - a.min" will give you a point3 with the object's bounding box dimensions...
03-22-2005, 04:01 PM
I guess I could create a temporary clone, rotate it so its aligned in world space. then use the 'max' and 'min' to find the size before deleting it. :shrug:
03-22-2005, 05:48 PM
I believe that a beter solution is to rotate your object, not make a clone ;)
but in fact you can retrieve the local coordinates of a vertex using 'coordsys local' command context.
If you create your own fonction to calculate the bouding box so you will not have to move the object.
I have already write this function for the UVW coordinates.. I search ...I search...
... and with a little modification:
fn getSize obj =
if objNumVerts>0 then
coord=coordsys local meshOp.getVert obj 1
minU=coord.x; minV=coord.y; minW=coord.z; maxU=coord.x; maxV=coord.y; maxW=coord.z
for v=2 to objNumVerts do
coord=coordsys local meshOp.getVert obj v
if coord.x<minU then minU=coord.x
if coord.y<minV then minV=coord.y
if coord.z<minW then minW=coord.z
if coord.x>maxU then maxU=coord.x
if coord.y>maxV then maxV=coord.y
if coord.z>maxW then maxW=coord.z
format "coordsys LOCAL : getsize obj=%\n" (getsize obj)
format "world pos : %\n" obj.pos
the array return 4 values: min, max, SIZE, center
sorry it's only for a MESH ! not for a primitive... but you can translate this for mesh by unsing a temporary edit mesh to read the positions.
offcourse it's beter to change minU --> minX ...
and you can use an another axis than the local axis. See 'coordsys' in the helpfile for more details about this.
03-22-2005, 06:13 PM
Rotating the acutal object will not work for my problem. So comparing all the verts might be the way to do it.
I'm not sure which way to go... I guess it's time to go home and sleep on it.
03-22-2005, 06:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.