0
$\begingroup$

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?

$\endgroup$
1
$\begingroup$

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)
0.30000000000000004
>>> print('{:.3g}'.format(val)) # '.3g' will give 3 significant digits
0.3

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.