Bounding box of selected verts in Edit Mesh

Is there any easy way to read the .max and .min points of a selection made in Edit Mesh?  I haven't been able to find any and my attempts at looping through the verts and recording the smallest and largest have been buggy.

 

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
recubo's picture

Maybe a different approach...

Maybe there is another way to do it...

You could create a spline object to connect those vertex and then get the bounding box of that spline.

denisT's picture

there is no easy way to get

there is no easy way to get bbox for selected verts. you have to go through all selected verts and look for min/max
Like this:

fn vertsBBox thenode verts: =
(
local themesh = thenode.mesh
if verts == unsupplied do verts = themesh.selectedVerts as bitarray

local minx = miny = minz = 1e9
local maxx = maxy = maxz = -1e9
for v in verts do
(
-- vert position in local coords
p = getVert themesh v
-- to get position in world coords
-- p *= thenode.transform
minx = amin minx p.x
miny = amin miny p.y
minz = amin minz p.z
maxx = amax maxx p.x
maxy = amax maxy p.y
maxz = amax maxz p.z
)
#([minx,miny,minz],[maxx,maxy,maxz])
)

if you want to make it faster don't use amin/amax
use if ... then ... else ...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.