The problem may be that you're not taking into account the mesh's minimum x/y/z.
Try doing:
s.mesh.min_x+(s.mesh.MeshWidth()/2.0)
...and similar for all the lines above. min_x/min_y/min_z store the position of the left-most, bottom-most, near-most vertex.
Generally though, I'd advise against using MeshWidth/Height etc. I'm sure there is probably an easier way to do what you're doing just using the standard Entity commands.
Try doing:
s.mesh.min_x+(s.mesh.MeshWidth()/2.0)
...and similar for all the lines above. min_x/min_y/min_z store the position of the left-most, bottom-most, near-most vertex.
Generally though, I'd advise against using MeshWidth/Height etc. I'm sure there is probably an easier way to do what you're doing just using the standard Entity commands.