MeshVertex.co - Vertex Position Issue

I’ve been recently jamming my head against importing .x models to my game by exporting them from Blender, and have decided to go on a tangent and write my own exporter instead. Apologies if this has been asked/answered elsewhere, I searched first and couldn’t come across it. Maybe I’m missing something obvious.

When trying to get a vertex position with ‘bpy.data.meshes[0].vertices[0].co’, it returns a Vector object that outputs as:

Vector (-1.0000, - 0.0000, -1.0000)

This is the correct position of the vertex. However, when trying to access that same object’s individual values, they output as the following:

bpy.data.meshes[0].vertices[0].co.x = -1.000000238418579
bpy.data.meshes[0].vertices[0].co.y = -1.7881393432617188e-07
bpy.data.meshes[0].vertices[0].co.z = -1.0

Besides the z value, these are completely wrong. It could be said that the x value is an estimate, but why would it change from the exact value it was showing before? And the y value is just completely wrong as far as I know.

Am I forgetting to transform it by a certain value? This has become very frustrating, especially since the official documentation just says it’s an array of three float values.

You can round them, like with 6 digits:
>>> round(-1.7881393432617188e-07,6)
-0.0

I see, thanks for the help. I ended up converting them using (’%f’, vert.co.x), etc. to get the right values out.

That y value is in scientific notation, so it isn’t as far off as it looks.

in standard notation that would be -0.00000017881393432617188

I’m not sure where the slight error comes from, but that one millionth of a unit shouldn’t throw your importer off any.

inside blender Vars are single precision
but python works with double precision !

so anything after 6 digits is not really valid only some noise from conversion !

happy bl