保留小数处理
This commit is contained in:
1 parent
a7575dddbf
commit
b1fb8fa7a0
1 file changed
+3
-2
+3
-2
@@ -61,8 +61,9 @@ def cal_weight(obj, size):
|
||||
# bpy.ops.wm.save_as_mainfile(filepath=os.path.join(config.workdir, action, pid, f'{pid}-{size/10}cm.blend'))
|
||||
model_info = {}
|
||||
bm = bmesh_copy_from_object(obj)
|
||||
model_info['volume'] = round(bm.calc_volume() / 1000)
|
||||
model_info['weight'] = round(model_info['volume'] * 1.226)
|
||||
# 保留三位小数
|
||||
model_info['volume'] = round(bm.calc_volume() / 1000, 3)
|
||||
model_info['weight'] = round(model_info['volume'] * 1.226, 2)
|
||||
print(f'{size/10}cm:体积 {model_info["volume"]}cm³, 克重 {model_info["weight"]}g')
|
||||
return model_info["weight"]
|
||||
|
||||
|
||||
Reference in new issue
Block a user