optimize_template_params
Optimize parametric 3D models by testing parameter combinations to find the structurally strongest design for functional parts.
Instructions
Find the structurally strongest version of a parametric template.
Sweeps each template parameter across its [min, max] range at
evenly spaced sample points, generates every combination via
OpenSCAD, runs structural analysis on each variant, and returns
the configuration with the highest structural score.
Use this when you want to **automatically** find optimal dimensions
for a functional part -- e.g. "what wall thickness and bracket
height give the strongest shelf bracket?"
:param template_id: Template ID from the design template library.
:param samples_per_param: Sample points per parameter (default 3).
:param max_variants: Maximum total variants to test (default 27).
:param constraints: JSON string of constraints, e.g.
``{"max_width_mm": 100, "max_height_mm": 50}``.
:param output_dir: Directory for generated STLs (temp dir if empty).
:returns: Dict with best_params, best_score, best_grade, best_stl_path,
variants_tested, all_scores, and summary.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| output_dir | No | ||
| constraints | No | ||
| template_id | Yes | ||
| max_variants | No | ||
| samples_per_param | No |