Browse Source

计算克重插入到指定的文件中

master
dongchangxi 11 months ago
parent
commit
7d929a0b19
  1. 21
      tools/cal_weight.py
  2. BIN
      tools/weights.xlsx

21
tools/cal_weight.py

@ -6,6 +6,7 @@ else:
sys.path.append('/data/deploy/make3d/make2/libs/') sys.path.append('/data/deploy/make3d/make2/libs/')
import config, libs, libs_db import config, libs, libs_db
import pandas as pd
def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False): def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False):
"""Returns a transformed, triangulated copy of the mesh""" """Returns a transformed, triangulated copy of the mesh"""
@ -73,12 +74,32 @@ def main(action, pid, sizes,orderId=0):
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
print(f'模型{pid}的体积与克重估算信息:') print(f'模型{pid}的体积与克重估算信息:')
arrData = {} 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: for size in sizes:
size = float(size) size = float(size)
weight = cal_weight(obj, size) weight = cal_weight(obj, size)
size = str(size/10)+"cm" size = str(size/10)+"cm"
arrData[size] = str(weight)+"g" 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} arrParams = {"pid":pid,"order_id":orderId}
if action == "auto": if action == "auto":

BIN
tools/weights.xlsx

Binary file not shown.
Loading…
Cancel
Save