dongchangxi 11 months ago
parent
commit
2358b9e02b
  1. 7
      tools/cal_weight_excel.py

7
tools/cal_weight_excel.py

@ -62,8 +62,9 @@ def cal_weight(obj, size): @@ -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"]
@ -99,7 +100,7 @@ def main(action, pid, sizes,orderId=0): @@ -99,7 +100,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

Loading…
Cancel
Save