optimize_template_params
Sweep template parameters, generate OpenSCAD variants, run structural analysis, and return the strongest configuration to optimize part dimensions.
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.INLINE 3D STAGE: on success this tool also opens Kiln's interactive 3D stage — an inline viewer panel the user can orbit, zoom, and turn over — in hosts that render MCP Apps panels (Kiln's hosted connection attaches a browser stage link for hosts that don't). Oversized meshes are decimated automatically for the stage; the PNG preview is the floor, not the whole experience.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| output_dir | No | ||
| constraints | No | ||
| template_id | Yes | ||
| max_variants | No | ||
| samples_per_param | No |