mapped fn createMiddleSpline node =
(
tm = node.transform
bb = nodeGetBoundingBox node tm
x = abs (bb[2].x - bb[1].x)
y = abs (bb[2].y - bb[1].y)
z = abs (bb[2].z - bb[1].z)
xx = #(x, y, z)
ss = #(x, y, z)
sort ss
i = finditem xx ss[2]
k = finditem xx ss[3]
if (i < k) do swap ss[2] ss[3]
rect = rectangle name:(node.name + "_sp") width:ss[3] length:ss[2] transform:tm wirecolor:(node.wirecolor * 0.6) parent:node
rect.center = node.center
n = finditem xx ss[1]
in coordsys tm
(
case n of
(
1: rotate rect (eulerangles 90 0 90)
2: rotate rect (eulerangles -90 0 0)
--3: rotate rect (eulerangles 0 0 0)
)
)
--format "% % % >> % >> %\n" x y z ss (finditem xx ss[1])
converttosplineshape rect
rect
)
delete objects
bb = for k=1 to 10 collect
(
box width:(random 10 100) length:(random 10 100) height:(random 10 100) \
pos:(random -[100,100,100] [100,100,100]) rotation:(eulerangles (random 0 180) (random 0 180) (random 0 180)) \
wirecolor:(random white black)
)
createMiddleSpline bb