This commit is contained in:
dongchangxi committed 2025-02-03 13:20:38 +08:00
commit 2358b9e02b
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')) # 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"]
@@ -99,7 +100,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