Trying to get the XY of a uv_layer[index].uv by using [0] and 1, or .x and .y, return extremely weird results. However using the uv value itself (e.g. print(uv_layer[index].uv)) gives correct results. Example:

enter image description here

This is not just a printing issue. When writing the values to a file, I get these same broken values in the file. Seems only that 0.0/0.0001 coords are broken maybe?

How do I obtain the correct X and Y values, individually?


1 Answer 1


That's not specifically a blender issue, it is showing the inaccuracy of representing a decimal number in binary storage. The python docs have a page explaining the issue and show some ways around it, the best is probably using format() which replaces the older '%.3g' % val style.

>>> val = 0.1 + 0.2
>>> print(val)
>>> print('{:.3g}'.format(val)) # '.3g' will give 3 significant digits

While python has the decimal module to better support decimal numbers, it doesn't help when working with blender's data.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .