mcpField
O
openscad-iterative-modeling

openscad-iterative-modeling

github.com/fboldoCreative & media8159 installsUpdated 5w ago
Repository

About openscad-iterative-modeling

openscad-iterative-modeling is a workflow for creating parametric 3D geometry through SCAD, PNG previews, and iterative refinement. It uses the OpenSCAD MCP Server to render previews and export STL files.

Key features

  1. 01Turn requests into modeling constraints
  2. 02Write parametric SCAD geometry
  3. 03Render PNGs and inspect shapes
  4. 04Refine models from preview feedback
  5. 05Export STL after approval

Use cases

  1. 01Create 3D brackets or enclosures from descriptions
  2. 02Reconstruct 3D models from object images
  3. 03Check rendered OpenSCAD code
  4. 04Export SCAD models as STL

MCP support

The workflow requires a configured, running OpenSCAD MCP Server. It uses render_scad_png for previews and export_scad_stl to export models.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/fboldo/openscad-mcp-server --skill openscad-iterative-modeling

After installing, type/openscad-iterative-modelingin Claude Code to confirm it loaded.

Details

From the project README

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 verifyCamera preset
Plan-view layout, hole positionstop
Heights, steps, lips, profilesfront or right
Overall shape, proportionsisometric
Underside featuresbottom
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, 40x30 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.

Comments

Markdown supported