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

This commit is contained in:
dongchangxi committed 2025-01-23 14:28:27 +08:00
1 parent 9362e5180e
commit 7d929a0b19
2 files changed
+21

No files matched your search

+21
View File
@@ -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}
Binary file not shown.