This commit is contained in:
dongchangxi committed 2025-02-03 13:20:30 +08:00
1 parent ff9da472e4
commit c335c78d68
1 file changed
+4 -3
+4 -3
View File
@@ -62,8 +62,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,2)
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"]
@@ -98,7 +99,7 @@ def main(action, pid, sizes,orderId=0):
arrData[arrSize[1]] = str(weight)+"g"
if arrSize[1] in df.columns:
new_data[arrSize[1]] = [weight]
new_data[arrSize[1]] = [str(weight) + "("+str(size)+"cm)"]
# 更新数据
# 将新数据转换为 DataFrame