How to identify one face of cube via Blender's Python API? I have been googling for a way to interrogate the 3d view using a script, to discover the locations of the faces of a cube. I have seen a lot of rather complex, daunting sample scripts creating cubes from scratch with primitives (vertex creation etc) but so far nothing that looks simple. If I have selected a cube successfully, as below:

ob = bpy.data.objects['Cube_7_7']
ob.select = True
bpy.context.scene.objects.active = ob
bpy.ops.object.mode_set(mode='EDIT')


(the intended cube lights up when selected and goes into edit mode, so I must have at least this basic syntax right)

How can I find out, say, the median point of the bottom face of this cube?  is this straightforward (i.e. is there a face naming convention relative to the cube's position at its creation)... or is it ugly?  basically, I want to identify the bottom faces of all my cubes.
This script should find the bottom face of the cube, not taking into consideration the cubes rotation.

import bpy
import bmesh

cube = bpy.context.active_object

bm = bmesh.new()
bm.from_mesh(cube.data)

minZ = float('inf')
for face in bm.faces:
    if face.calc_center_bounds()[2] &lt; minZ:
        minZ = face.calc_center_bounds()[2]
        bottom_face = face

cube.data.polygons[bottom_face.index].select = True
print('The bottom face is '+str(bottom_face))


Thus, you will need to either apply rotation (Ctrl + A) to all cubes or use the global Z, like this

import bpy
import bmesh

cube = bpy.context.active_object

bm = bmesh.new()
bm.from_mesh(cube.data)

minZ = float('inf')
for face in bm.faces:
    Z = (cube.matrix_world * face.calc_center_bounds())[2] ## This line is different
    if Z &lt; minZ:
        minZ = Z
        bottom_face = face

cube.data.polygons[bottom_face.index].select = True
print(bottom_face)       


EDIT: Simpler code without using bmesh

import bpy

cube = bpy.context.active_object
mesh = cube.data

minZ = float('inf')
for face in mesh.polygons:
    Z = face.center[2]
    if Z &lt; minZ:
        minZ = Z
        bottom_face = face

bottom_face.select = True
print('The bottom face is '+str(bottom_face))


for global coordinates replace the line 

Z = face.center[2]


with 

Z = (cube.matrix_world * face.center)[2]