Fix: FEM part lookup (exclude _i.prt), hole_count unit (Constant not mm), add file logging
- solve_simulation.py: FEM finder now excludes idealized parts, falls back to loading .fem - solve_simulation.py: hole_count written as [Constant] not [MilliMeter] in .exp - run_doe.py: dual logging to console + results/doe_run.log
This commit is contained in:
@@ -934,10 +934,21 @@ def solve_simple_workflow(
|
||||
|
||||
# Write expressions to temp file and import
|
||||
exp_file_path = os.path.join(working_dir, "_temp_expressions.exp")
|
||||
|
||||
# Known integer/constant expressions (no unit)
|
||||
CONSTANT_EXPRESSIONS = {
|
||||
"hole_count",
|
||||
}
|
||||
|
||||
with open(exp_file_path, "w") as f:
|
||||
for expr_name, expr_value in expression_updates.items():
|
||||
# Determine unit based on name
|
||||
if "angle" in expr_name.lower():
|
||||
# Determine unit based on expression type
|
||||
if expr_name in CONSTANT_EXPRESSIONS:
|
||||
unit_str = "Constant"
|
||||
# Write as integer if it's a whole number
|
||||
if expr_value == int(expr_value):
|
||||
expr_value = int(expr_value)
|
||||
elif "angle" in expr_name.lower():
|
||||
unit_str = "Degrees"
|
||||
else:
|
||||
unit_str = "MilliMeter"
|
||||
@@ -1009,14 +1020,32 @@ def solve_simple_workflow(
|
||||
print(f"[JOURNAL] WARNING: Could not load idealized part: {e}")
|
||||
break
|
||||
|
||||
# Find the FEM part
|
||||
# Find the FEM part (must be .fem, NOT _i.prt idealized part)
|
||||
fem_part = None
|
||||
for part in theSession.Parts:
|
||||
if "_fem" in part.Name.lower() or part.Name.lower().endswith(".fem"):
|
||||
part_name = part.Name.lower()
|
||||
# Match FEM parts but exclude idealized parts (_i)
|
||||
if ("_fem" in part_name or part_name.endswith(".fem")) and "_i" not in part_name.split("_fem")[-1]:
|
||||
fem_part = part
|
||||
print(f"[JOURNAL] Found FEM part: {part.Name}")
|
||||
break
|
||||
|
||||
# If not found by name, try loading .fem file from working directory
|
||||
if fem_part is None:
|
||||
for filename in os.listdir(working_dir):
|
||||
if filename.lower().endswith(".fem"):
|
||||
fem_path = os.path.join(working_dir, filename)
|
||||
print(f"[JOURNAL] Loading FEM file: {filename}")
|
||||
try:
|
||||
loaded_part, partLoadStatus = theSession.Parts.Open(fem_path)
|
||||
partLoadStatus.Dispose()
|
||||
if loaded_part is not None:
|
||||
fem_part = loaded_part
|
||||
print(f"[JOURNAL] FEM part loaded: {fem_part.Name}")
|
||||
break
|
||||
except Exception as e:
|
||||
print(f"[JOURNAL] WARNING: Could not load FEM: {e}")
|
||||
|
||||
if fem_part:
|
||||
try:
|
||||
# Switch to FEM part - CRITICAL: Use SameAsDisplay to make FEM the work part
|
||||
|
||||
Reference in New Issue
Block a user