diff --git a/tools/cal_weight.py b/tools/cal_weight.py index 0194643..2cd5bbd 100644 --- a/tools/cal_weight.py +++ b/tools/cal_weight.py @@ -6,6 +6,7 @@ else: sys.path.append('/data/deploy/make3d/make2/libs/') import config, libs, libs_db +import pandas as pd def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False): """Returns a transformed, triangulated copy of the mesh""" @@ -73,11 +74,31 @@ def main(action, pid, sizes,orderId=0): bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) print(f'模型{pid}的体积与克重估算信息:') arrData = {} + excel_file = 'weights.xlsx' # 替换为你的文件路径 + df = pd.read_excel(excel_file) + new_data = { + 'pid': [pid], # 假设新的 pid 是 '002' + '6cm': [0], # 新的 6cm 数据 + '7cm': [0], # 新的 7cm 数据 + '8cm': [0], # 新的 8cm 数据 + } + for size in sizes: size = float(size) weight = cal_weight(obj, size) size = str(size/10)+"cm" arrData[size] = str(weight)+"g" + + if size+"cm" in df.columns: + new_data[size+"cm"] = [weight] + + # 更新数据 + # 将新数据转换为 DataFrame + new_df = pd.DataFrame(new_data) + # 将新数据附加到原始 DataFrame 中 + df = pd.concat([df, new_df], ignore_index=True) + # 保存更新后的 Excel 文件 + df.to_excel(excel_file, index=False) #请求接口进行更新数据 arrParams = {"pid":pid,"order_id":orderId} diff --git a/tools/weights.xlsx b/tools/weights.xlsx new file mode 100644 index 0000000..90f7032 Binary files /dev/null and b/tools/weights.xlsx differ