开发者

Python Blender math.trunc()

开发者 https://www.devze.com 2023-03-02 23:39 出处:网络
iam trying to use the math.trunc in Blender 2.49b Python but iam getting this error AttributeError: \'module\' object has no attribute \'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 vi开发者_开发技巧a 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


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')


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号