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.
Forum topic · General Scripting
By WillyWonka · 2008-02-08
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 (2)
Comment policy
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.
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 ...