openscad-iterative-modeling

📁 fboldo/openscad-mcp-server 📅 2 days ago
1
总安装量
1
周安装量
#47210
全站排名
安装命令
npx skills add https://github.com/fboldo/openscad-mcp-server --skill openscad-iterative-modeling

Agent 安装分布

amp 1
opencode 1
kimi-cli 1
github-copilot 1
gemini-cli 1

Skill 文档

OpenSCAD iterative modeling loop (SCAD → PNG → refine)

When to Use This Skill

  • The user asks to create, design, or model a 3D object (bracket, enclosure, mount, gear, etc.)
  • The user sends a picture of an object and asks to recreate it in 3D
  • The user wants to render or preview OpenSCAD code
  • The user asks to export an STL file from a SCAD description
  • Any request that can be expressed as parametric CSG geometry

Prerequisites

Required Tools

  • OpenSCAD MCP Server: Required for rendering and exporting OpenSCAD geometry
    • Enables: render_scad_png (SCAD → PNG preview), export_scad_stl (SCAD → STL mesh)
    • Tool names may be namespaced by the host (e.g. mcp_openscad-mcp-_render_scad_png); match by suffix
    • Must be configured and running to render previews and export models

Operating mode

  • Prefer small, parametric SCAD with named variables.
  • Each iteration: change only what the PNG critique indicates.
  • After 3 render-refine cycles without convergence, stop and ask the user for clarification.

Workflow

1. Normalize the request (minimal clarifications)

Extract and confirm only what you must to model correctly:

  • Units (default to mm if unspecified)
  • Critical dimensions (overall size, hole diameters, wall thickness)
  • Constraints (must be printable? tolerance? symmetry? sharp vs filleted edges?)

If key dimensions are missing, ask 1–3 questions. Otherwise proceed with reasonable defaults and state them.

2. Draft SCAD code (first pass)

  • Use module with named parameters.
  • Center geometry at the origin when practical (center=true).
  • Set $fn explicitly for curved parts (start with $fn=64).
  • Ensure cutters in difference() extend beyond the body to avoid zero-thickness walls.

3. Render a PNG preview

Render with cameraPreset="isometric" first (width=800, height=600). If features are hard to judge, add orthographic views:

Feature to verify Camera preset
Plan-view layout, hole positions top
Heights, steps, lips, profiles front or right
Overall shape, proportions isometric
Underside features bottom

4. Visually critique the PNG

Run through this checklist (in order of priority):

  1. Render valid? — If blank/error, see §Render failures below.
  2. Overall proportions — Does the bounding shape match the request?
  3. Feature presence — Are all holes, cutouts, chamfers, and fillets visible?
  4. Placement & alignment — Centered? Symmetric? Correct offsets?
  5. Orientation — Is the part oriented for its intended use (e.g. printable flat side down)?

Write a one-line verdict per issue found, e.g.:

  • “Through-hole is off-center by ~5 mm — shift translate X by +5.”
  • “Lip is too tall (6 mm → reduce to 2 mm).”

5. Refine SCAD code and repeat

Apply the smallest SCAD change that addresses the critique, then render again.

Stop when the PNG matches the user’s intent and the user approves.

6. Export STL (only when ready)

Once approved, export the geometry:

  • Choose a stable filename (e.g. "bracket.stl").
  • If the user wants multiple variants, export each with a distinct filename.

Render failures

If a render returns blank or errors:

  1. Simplify the SCAD to a minimal shape (e.g. a cube) to confirm the tool is working.
  2. Re-add features one at a time, rendering after each addition, to isolate the problem.
  3. Common causes: syntax error, difference() ordering, negative dimension, cutter not intersecting body.

Example loop

User request: “L-bracket, 40×30 mm base, 25 mm tall wall, 4 mm thick, two M4 countersunk mounting holes in the base.”

  1. Draft SCAD:
$fn = 64;
t = 4; base_w = 40; base_d = 30; wall_h = 25;
hole_d = 4.3; csink_d = 8.5; csink_depth = 2.4;
hole_x = [10, 30]; hole_y = 15;

difference() {
  union() {
    cube([base_w, base_d, t]);                      // base
    translate([0, 0, 0]) cube([t, base_d, wall_h]);  // wall
  }
  for (x = hole_x) {
    translate([x, hole_y, -1]) cylinder(h = t + 2, d = hole_d);
    translate([x, hole_y, t - csink_depth]) cylinder(h = csink_depth + 1, d1 = hole_d, d2 = csink_d);
  }
}
  1. Render isometric -> critique: wall is on the wrong edge; move to x = base_w - t.
  2. Fix, render top -> holes look correctly spaced. Render front -> wall height correct.
  3. User approves -> export STL.