Peter Lapisu
Peter Lapisu

Reputation: 20975

Python Blender math.trunc()

iam trying to use the math.trunc in Blender 2.49b Python

but iam getting this error

AttributeError: 'module' object has no attribute 'trunc'

i also imported math

its on line

uv[i][0] = trunc(uv[i][0] * 100000) / 100000

i also tryied it via the int, like

uv[i][0] = int(uv[i][0] * 100000) / 100000

which gives me an error

TypeError: 'float' object is unsubscriptable

so how should i trunc the value:(

thank you

Upvotes: 1

Views: 2293

Answers (2)

George Profenza
George Profenza

Reputation: 51837

It might depend what verson of Python is used by Blender (I imagine that would be Python 2.5).

Try this in Blender:

import math
help(math)

This will crash Blender, but you will be able to see the math to the library under FILE and you should be able to scroll down to see if the trunc function is available in the version of Python used by Blender. It might be not present, which would explain the error.

Upvotes: 1

Senthil Kumaran
Senthil Kumaran

Reputation: 56841

The second error seems to imply that uv in your code is a float object and you are trying to subscript it uv[i]. Try to math.trunc(uv) and see. Also you can check if trunc is available by doing hasattr(math,'trunc')

Upvotes: 1

Related Questions