Selection of points with x-coordinate maximum

For a personal project, I need for example on a cube that would have made ​​a rotation along z angle of PI / 4 to write a python program that will permit to select the points that have the maximum x coordinate, i mean that for example if you made ​​a list of all the x-coordinate of the vertices constituting the cube, and well most of this list will be the x-coordinate of the point I wish to select. Here is the code I use on a cube:

def sectionner1():
tx = []
truc =
bpy.ops.mesh.select_all(action = ‘DESELECT’)
bm = bmesh.from_edit_mesh(
for vert in bm.verts:
for vertices in bm.verts:
if[0] == maximum(tx): = True
bpy.ops.mesh.select_all(action =‘INVERT’)

It selects me the good part when I’m not turning my cube, but once I made ​​a rotation, and although it does not give the correct result anymore … If someone has a solution!

You need to transform the vertex coordinate from object space to world space, e.g.:

obj.matrix_world *

Test on the resulting Vector and it should work.

yeah, but it shouldn’t be necessary to turn the coordinate into 4d for that

True, I just copied and pasted from a personal project.