Notifications
Clear all

[Closed] help ,How to calculate many box ,total length, total width, total height?

help ,
How to calculate many box ,total length, total width, total height Respectively?
I write a simple code, but have message,

if selection.count > 0 do
p = #()
p = for i in selection where isGroupMember i == false collect i

for n = 2 to ( p.count – 1 ) do
(
moo = (p[n].max -p[n].min).x

)

how to Cumulative?

6 Replies

Have you seen Maxscript help for Bounding Box?

nodeGetBoundingBox <node> <matrix3>

Returns a 2 element array containing the min and max points of the node's bounding box in coordinate system matrix3 as point3 values. Positions returned are always in the specified matrix3 coordinate system.

Available in 3ds Max 2008 and higher. Previously available in the [AVG] Avguard Extensions.

FOR EXAMPLE:
 
 

--Create a teapot and a camera (turn on Orthographic Projection). Run:

bb= nodeGetBoundingBox $teapot01 $camera01.transform

in coordsys $camera01 point pos:bb[1]

in coordsys $camera01 point pos:bb[2]

--Note that this does not correct for the camera's FOV.

 
 

 

nodeLocalBoundingBox <node>

Returns a 2 element array containing the min and max points of the node's local bounding box. Positions returned are in the current coordinate system.

Available in 3ds Max 2008 and higher. Previously available in the [AVG] Avguard Extensions.

FOR EXAMPLE:
 
 

--Create a teapot. Run:

bb= nodeLocalBoundingBox $teapot01

point pos:bb[1]

point pos:bb[2]

Sorry My maxscript is poor。
Specifically how to do? I would like to use my method, it should be used loop and Cumulative?
These two I do not know too.

1 Reply
(@panayot)
Joined: 11 months ago

Posts: 0

is this what you want?..

if selection.count > 0 do
(
	myCollection = for i in selection where not isGroupMember i collect i
 
	total = [0,0,0]
	for obj in myCollection do (total += obj.max - obj.min)
 
	format "Total X-size: %
" total[1]
	format "Total Y-size: %
" total[2]
	format "Total Z-size: %
" total[3]
)

Thanks, This is Iwant.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i don’t like to be rude but what you want to know doesn’t make any sense…
i’m absolutely sure that you want to know a bounding box of a node collection (selection, group, etc.)
everything is simple… max gives the min/max for the selection… which is simple as:


-- selection.min and selection.max

-- the dimension of the selection is:
selection.max - selection.min
-- which is a point3 >> [width,length,height] of the selection bounding box in world coordinate system

Yeah, Denis, the same I thought at the beginning but a repetition of the “cumulative” made me think that he want to do extra calculations (like average bb value for ex.).

However, when I help I follow 2 (my own) basic rules (well proven I think):

  1. Helping to rookie needs strong patience.
  2. Giving more aid than requested (usually) is a waste of time.

I saw a new topic from su37 and it is possible he to need an array of bounding boxes, but who knows