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

7
tools/cal_weight_excel.py

@ -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')) # bpy.ops.wm.save_as_mainfile(filepath=os.path.join(config.workdir, action, pid, f'{pid}-{size/10}cm.blend'))
model_info = {} model_info = {}
bm = bmesh_copy_from_object(obj) 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') print(f'{size/10}cm:体积 {model_info["volume"]}cm³, 克重 {model_info["weight"]}g')
return model_info["weight"] return model_info["weight"]
@ -98,7 +99,7 @@ def main(action, pid, sizes,orderId=0):
arrData[arrSize[1]] = str(weight)+"g" arrData[arrSize[1]] = str(weight)+"g"
if arrSize[1] in df.columns: if arrSize[1] in df.columns:
new_data[arrSize[1]] = [weight] new_data[arrSize[1]] = [str(weight) + "("+str(size)+"cm)"]
# 更新数据 # 更新数据
# 将新数据转换为 DataFrame # 将新数据转换为 DataFrame

Loading…
Cancel
Save