x
This commit is contained in:
+104
-25
@@ -507,10 +507,27 @@ async def process_file_core(
|
||||
surface_area_mm2 = geometry_data.get("surface_area", 0)
|
||||
bbox = geometry_data.get("bounding_box", {})
|
||||
bbox_dims = bbox.get("dimensions", [0, 0, 0])
|
||||
|
||||
# 材料属性(可根据用户选择或自动检测)
|
||||
material_properties = {
|
||||
"ABS": {"density": 1.05, "shrinkage": 0.005, "name": "ABS"},
|
||||
"PP": {"density": 0.90, "shrinkage": 0.016, "name": "PP"},
|
||||
"PE": {"density": 0.95, "shrinkage": 0.020, "name": "PE"},
|
||||
"PC": {"density": 1.20, "shrinkage": 0.007, "name": "PC"},
|
||||
"PA": {"density": 1.14, "shrinkage": 0.010, "name": "PA"},
|
||||
"POM": {"density": 1.41, "shrinkage": 0.020, "name": "POM"},
|
||||
"PMMA": {"density": 1.18, "shrinkage": 0.005, "name": "PMMA"},
|
||||
"PBT": {"density": 1.31, "shrinkage": 0.015, "name": "PBT"},
|
||||
}
|
||||
|
||||
# 默认使用 ABS
|
||||
selected_material = material_properties["ABS"]
|
||||
material_density = selected_material["density"]
|
||||
shrinkage_rate = selected_material["shrinkage"]
|
||||
|
||||
# 计算产品重量(ABS密度:1.05 g/cm³)
|
||||
# 计算产品重量
|
||||
volume_cm3 = volume_mm3 / 1000
|
||||
product_weight_g = volume_cm3 * 1.05
|
||||
product_weight_g = volume_cm3 * material_density
|
||||
|
||||
# 计算投影面积(取X、Y方向)
|
||||
if len(bbox_dims) >= 2:
|
||||
@@ -518,8 +535,40 @@ async def process_file_core(
|
||||
else:
|
||||
projected_area_cm2 = 0
|
||||
|
||||
# 计算夹紧力(投影面积 × 注塑压力600 kg/cm²,转换为吨)
|
||||
clamping_force_ton = int(projected_area_cm2 * 600 / 1000)
|
||||
# 计算最优型腔数量
|
||||
# 基于产品重量和投影面积计算
|
||||
# 小产品(< 100g)可以多型腔,大产品(> 1000g)通常单型腔
|
||||
if product_weight_g < 50:
|
||||
cavity_count = 8 # 小产品,多型腔
|
||||
elif product_weight_g < 100:
|
||||
cavity_count = 4 # 中小产品
|
||||
elif product_weight_g < 300:
|
||||
cavity_count = 2 # 中等产品
|
||||
elif product_weight_g < 1000:
|
||||
cavity_count = 1 # 较大产品
|
||||
else:
|
||||
cavity_count = 1 # 大产品,单型腔
|
||||
|
||||
# 根据投影面积调整型腔数量
|
||||
# 如果单型腔投影面积超过 400 cm²,减少型腔数量
|
||||
single_cavity_area = projected_area_cm2
|
||||
if single_cavity_area > 400:
|
||||
cavity_count = 1
|
||||
elif single_cavity_area > 200 and cavity_count > 2:
|
||||
cavity_count = 2
|
||||
|
||||
# 计算总投影面积(包括流道系统)
|
||||
# 流道系统约占型腔投影面积的 15-25%
|
||||
runner_ratio = 0.20
|
||||
total_projected_area = single_cavity_area * cavity_count * (1 + runner_ratio)
|
||||
|
||||
# 计算夹紧力(总投影面积 × 注塑压力 / 1000 吨)
|
||||
# 注塑压力根据材料选择:ABS 约 600-800 kg/cm²
|
||||
injection_pressure = 700 # kg/cm²
|
||||
clamping_force_ton = int(total_projected_area * injection_pressure / 1000)
|
||||
|
||||
# 确保夹紧力在合理范围内
|
||||
clamping_force_ton = max(50, min(clamping_force_ton, 3000))
|
||||
|
||||
# 计算壁厚范围
|
||||
if surface_area_mm2 > 0 and volume_mm3 > 0:
|
||||
@@ -537,29 +586,55 @@ async def process_file_core(
|
||||
else:
|
||||
complexity_score = 0.5
|
||||
|
||||
# 计算模具尺寸(基于产品尺寸 + 模具边距)
|
||||
mold_length = max(bbox_dims[0] if len(bbox_dims) > 0 else 120, 120) + 40
|
||||
mold_width = max(bbox_dims[1] if len(bbox_dims) > 1 else 100, 100) + 40
|
||||
mold_height = max(bbox_dims[2] if len(bbox_dims) > 2 else 60, 60) + 50
|
||||
# 计算模具尺寸(基于型腔布局)
|
||||
# 单型腔:产品尺寸 + 边距
|
||||
# 多型腔:需要考虑型腔排列
|
||||
cavity_spacing = 30 # 型腔间距 mm
|
||||
edge_margin = 50 # 边缘余量 mm
|
||||
|
||||
if cavity_count == 1:
|
||||
mold_length = max(bbox_dims[0] if len(bbox_dims) > 0 else 120, 120) + 2 * edge_margin
|
||||
mold_width = max(bbox_dims[1] if len(bbox_dims) > 1 else 100, 100) + 2 * edge_margin
|
||||
elif cavity_count == 2:
|
||||
# 2型腔:并排排列
|
||||
mold_length = 2 * max(bbox_dims[0] if len(bbox_dims) > 0 else 120, 120) + cavity_spacing + 2 * edge_margin
|
||||
mold_width = max(bbox_dims[1] if len(bbox_dims) > 1 else 100, 100) + 2 * edge_margin
|
||||
elif cavity_count == 4:
|
||||
# 4型腔:2x2 排列
|
||||
mold_length = 2 * max(bbox_dims[0] if len(bbox_dims) > 0 else 120, 120) + cavity_spacing + 2 * edge_margin
|
||||
mold_width = 2 * max(bbox_dims[1] if len(bbox_dims) > 1 else 100, 100) + cavity_spacing + 2 * edge_margin
|
||||
else:
|
||||
# 8型腔:2x4 排列
|
||||
mold_length = 4 * max(bbox_dims[0] if len(bbox_dims) > 0 else 120, 120) + 3 * cavity_spacing + 2 * edge_margin
|
||||
mold_width = 2 * max(bbox_dims[1] if len(bbox_dims) > 1 else 100, 100) + cavity_spacing + 2 * edge_margin
|
||||
|
||||
mold_height = max(bbox_dims[2] if len(bbox_dims) > 2 else 60, 60) + 80 # 包含冷却系统
|
||||
|
||||
# 计算分型线长度(基于产品周长)
|
||||
# 计算分型线长度(基于型腔布局)
|
||||
if len(bbox_dims) >= 2:
|
||||
parting_line_length = 2 * (bbox_dims[0] + bbox_dims[1])
|
||||
single_parting_line = 2 * (bbox_dims[0] + bbox_dims[1])
|
||||
parting_line_length = single_parting_line * cavity_count
|
||||
else:
|
||||
parting_line_length = 0
|
||||
|
||||
# 估算成型周期(基于体积)
|
||||
# 估算成型周期(基于体积和壁厚)
|
||||
# 周期 = 冷却时间 + 注塑时间 + 开合模时间
|
||||
cooling_time = (wall_thickness_max ** 2) * 5 # 简化公式
|
||||
injection_time = max(5, volume_cm3 / 50) # 注塑时间
|
||||
cycle_time = cooling_time + injection_time + 8 # 开合模约8秒
|
||||
cooling_time = (wall_thickness_max ** 2) * 4 # 冷却时间与壁厚平方成正比
|
||||
injection_time = max(3, volume_cm3 / 100) # 注塑时间
|
||||
ejection_time = 3 # 顶出时间
|
||||
cycle_time = cooling_time + injection_time + ejection_time + 5 # 开合模约5秒
|
||||
|
||||
# 根据型腔数量调整周期(多型腔需要更长冷却时间)
|
||||
if cavity_count > 1:
|
||||
cycle_time = cycle_time * (1 + 0.1 * (cavity_count - 1))
|
||||
|
||||
detailed_cavity_json = {
|
||||
"metadata": {
|
||||
"file_name": Path(file_path).name,
|
||||
"analysis_date": datetime.now().isoformat(),
|
||||
"shrinkage_rate": 0.005,
|
||||
"draft_angle": 2.0
|
||||
"shrinkage_rate": shrinkage_rate,
|
||||
"draft_angle": 2.0,
|
||||
"selected_material": selected_material["name"]
|
||||
},
|
||||
"product_analysis": {
|
||||
"volume": volume_mm3,
|
||||
@@ -567,32 +642,36 @@ async def process_file_core(
|
||||
"bounding_box": bbox
|
||||
},
|
||||
"manufacturing_info": {
|
||||
"recommended_material": "ABS",
|
||||
"recommended_material": selected_material["name"],
|
||||
"material_density": f"{material_density} g/cm³",
|
||||
"estimated_clamping_force": f"{clamping_force_ton} 吨",
|
||||
"estimated_mold_size": {
|
||||
"length": int(mold_length),
|
||||
"width": int(mold_width),
|
||||
"height": int(mold_height)
|
||||
},
|
||||
"mold_material": "铝合金7075",
|
||||
"mold_hardness": "HB 150-170",
|
||||
"mold_material": "铝合金7075" if clamping_force_ton < 200 else "P20钢材",
|
||||
"mold_hardness": "HB 150-170" if clamping_force_ton < 200 else "HRC 28-32",
|
||||
"surface_finish": "Ra 0.8 μm",
|
||||
"parting_line_length": f"{parting_line_length:.2f} mm",
|
||||
"estimated_cycle_time": f"{int(cycle_time)} 秒"
|
||||
"estimated_cycle_time": f"{int(cycle_time)} 秒",
|
||||
"injection_pressure": f"{injection_pressure} kg/cm²"
|
||||
},
|
||||
"mold_cavities": {
|
||||
"cavity_count": 1,
|
||||
"cavity_count": cavity_count,
|
||||
"cavity_layout": "single" if cavity_count == 1 else f"{cavity_count} cavities",
|
||||
"cavity_key_info": {
|
||||
"geometric_characteristics": {
|
||||
"product_weight": f"{product_weight_g:.2f} g",
|
||||
"wall_thickness_range": f"{wall_thickness_min:.2f} - {wall_thickness_max:.2f} mm",
|
||||
"complexity_score": round(complexity_score, 2),
|
||||
"product_volume": f"{volume_cm3:.2f} cm³"
|
||||
"product_volume": f"{volume_cm3:.2f} cm³",
|
||||
"projected_area": f"{projected_area_cm2:.2f} cm²"
|
||||
},
|
||||
"quality_considerations": {
|
||||
"potential_weld_lines": "center",
|
||||
"sink_mark_areas": "thick_sections",
|
||||
"warpage_risk": "low"
|
||||
"potential_weld_lines": "center" if cavity_count > 1 else "minimal",
|
||||
"sink_mark_areas": "thick_sections" if wall_thickness_max > 4 else "minimal",
|
||||
"warpage_risk": "medium" if wall_thickness_max > 5 else "low"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user