I'm writing a python script to get the southwestern vertex of the selected object, and get its coordinates X, Y and Z.
Logically the southwestern point would match the vertex having the minimum X, Y and Z. How can I access theses values in python?
So far I've been able to get the min XYZ values of the object, but it's resulting the bounding box values which is not the expected result. Instead I need the vertex values.
Can someone guide me through?
from pymxs import runtime as rt
aSelect = rt.selection[0]
minX = aSelect.min.x
minY = aSelect.min.y
minZ = aSelect.min.z
'Southwestern' point is kinda open to interpretation (for example, I don't see the Z in the name), for the sake of argument let's pick the two most likely - one that gets the vertex that's furthest away from the object max, and one that get the vertex with the smallest total of x+y+x coords:
from pymxs import runtime as rt
obj = rt.selection[0]
mesh = rt.snapshotAsMesh(obj)
minDiagonalVert = max(list(mesh.verts), key=lambda vert: rt.distance(vert.pos, obj.max))
minTotalVert = min(list(mesh.verts), key=lambda vert: vert.pos.x + vert.pos.y + vert.pos.z)
rt.delete(mesh)
Quite obviously, this will work only for some kind of meshes, but that's up to you to set your own criteria that you want to match in that case.