Skip to content

larszu/openscad-vision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

37 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OpenSCAD ร— AI Vision

OpenSCAD ร— AI Vision

Drop in a photo โ€“ get a 3D model. A native desktop app that turns photos (or text descriptions) into parametric OpenSCAD models using Anthropic Claude, OpenAI, or Google Gemini โ€“ with an interactive 3D viewer, STL export, and "Open in OpenSCAD" for fine-tuning.

Release License Build


Download (Windows)

โ†’ Download latest version

File Description
OpenSCAD-Claude-Vision-Setup-x.x.x.exe Installer with desktop shortcut & start menu entry
OpenSCAD-Claude-Vision-Portable-x.x.x.exe Portable EXE, just run โ€“ no installation required

Requirement: OpenSCAD must be installed separately (used for rendering models).


Features

Feature Description
๐Ÿง  Multi-provider AI Pick Anthropic Claude, OpenAI, or Google Gemini โ€“ each with its own key & model
๐Ÿ“ท Photo โ†’ 3D Upload one photo, the AI analyzes it and generates OpenSCAD code
๐ŸงŠ Multi-view โ†’ 3D Upload several photos (front/back/sides/top) and label them; the AI cross-references views for far more accurate models
๐Ÿ“ธ Webcam capture Take photos straight from the device camera โ€“ ideal for scanning all sides of an object
๐Ÿ’ฌ Text โ†’ 3D Enter a description only โ€“ no photo required
๐Ÿ”„ Refine via chat "Make the walls thicker", "Add a hole on top" โ€“ the AI updates the code
๐Ÿ›  Auto-fix on render error When the generated SCAD fails to render, the AI is sent the error and retries automatically
โš™๏ธ Live parameter sliders Numeric variables at the top of the SCAD are exposed as sliders for tweaking without code edits
๐Ÿ†š Refinement diff view See exactly what changed between iterations โ€“ added/removed lines side-by-side
๐Ÿ” 6-view inspection One click renders the model from front/back/left/right/top/bottom โ€“ validate every side at once
๐Ÿ”ฌ AI printability check The active AI reviews the SCAD for FDM print issues (wall thickness, overhangs, hole sizes) and returns a scored report with fixes
๐Ÿงฑ Fillet/Chamfer/Shell helpers System prompt teaches the AI to use minkowski-based fillet/chamfer and offset-based shell โ€“ features OpenSCAD doesn't have natively
๐Ÿ“ Phased construction The AI is instructed to build in 3 phases (base shape โ†’ features โ†’ finish) โ€“ more reliable than monolithic generation
๐Ÿ–จ Open in slicer One-click launch in PrusaSlicer / Bambu Studio / Cura, or fall back to the OS default app for STL
๐Ÿ“ฆ 3MF export Alongside STL, models export to .3mf when OpenSCAD supports it โ€“ preferred by modern slicers
๐ŸŽฎ Interactive 3D viewer Rotate and zoom STL in the browser (WASD + mouse + Space/Shift)
๐Ÿ’พ STL export Export the model directly for slicers and 3D printers
โฌก Open in OpenSCAD Writes a .scad file locally and launches OpenSCAD with auto-reload
๐Ÿ“š Model history All generated models remain as thumbnails in the sidebar
๐Ÿ”ง Parametric Code always includes variables at the top โ€“ easy to tweak in OpenSCAD
โš™๏ธ API key in UI No config files needed โ€“ key is stored in the app

Quick Start

Option 1: Prebuilt EXE (recommended)

  1. Install OpenSCAD: openscad.org/downloads

  2. Download the app: Releases โ†’ Setup or Portable EXE

  3. Launch โ€“ you'll be prompted for your API key on first start

  4. Get an API key from any supported provider:

    You can save keys for all three and switch the active provider in the settings panel anytime.

Option 2: From source (Linux / macOS / Windows dev)

git clone https://github.com/larszu/openscad-vision.git
cd openscad-vision/openscad-api
npm install
npm start

OpenSCAD must be installed:

  • Ubuntu/Debian: sudo apt install openscad xvfb
  • macOS: brew install openscad
  • Windows: see below or install manually

Windows from source

git clone https://github.com/larszu/openscad-vision.git
cd openscad-vision\openscad-api
powershell -ExecutionPolicy Bypass -File setup-windows.ps1
.\start.bat

Build your own EXE: .\build-exe.bat โ†’ output in dist\


Usage

Photo โ†’ 3D

  1. Drag & drop one or more photos into the upload area (multiple files at once supported)
  2. Optional: add a hint ("Only show the base of the object")
  3. Click Generate
  4. Claude analyzes the image(s) and generates OpenSCAD code
  5. Model appears in the interactive 3D viewer with code alongside

Tip: For accurate models, upload several views of the same object (e.g. front, back, sides, top, bottom โ€“ up to 6 sides for a cube-like object). Claude Vision cross-references the views to reconstruct depth and details that a single photo can't capture.

Text โ†’ 3D

No photo needed โ€“ just describe it:

Cylindrical container with screw lid, height twice the diameter

Refinement

Use the chat panel to modify:

Make the walls thicker Add a 10mm hole on top Scale everything to 50%

3D Viewer Controls

Input Action
Mouse drag Orbit / rotate
Scroll wheel Zoom
W / S Forward / backward
A / D Left / right
Space Up
Shift Down
PNG button Toggle: 3D viewer โ†” OpenSCAD render

Open in OpenSCAD

Click "Open in OpenSCAD" to write the file to ~/openscad-live.scad (Windows: %USERPROFILE%\openscad-live.scad) and launch OpenSCAD.

Tip: Enable Design โ†’ Automatic Reload and Preview in OpenSCAD to auto-refresh on each update.


REST API

The app runs a local server on port 3333:

Method Path Description
GET /api/settings API key status
POST /api/settings Save API key
POST /api/generate Image or text โ†’ OpenSCAD code + render
POST /api/refine Code + request โ†’ updated code
POST /api/render Render SCAD code directly
POST /api/open-in-openscad Open in OpenSCAD GUI
GET /api/models List all saved models
GET /api/scad/:id Fetch SCAD source
GET /output/:id.stl Download STL

Example: text-to-3D via curl

curl -X POST http://localhost:3333/api/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Cube with rounded edges, 30mm"}'

Configuration

Settings are stored per user:

Platform Path
Windows %APPDATA%\openscad-claude-vision\
macOS ~/Library/Application Support/openscad-claude-vision/
Linux ~/.config/openscad-claude-vision/ (Electron) or ~/.openscad-claude/ (Standalone)

Contents:

  • settings.json โ€“ API key, settings
  • models/ โ€“ generated .scad files
  • output/ โ€“ PNG previews and STL files

Help โ†’ Open Data Folder reveals the path in your file explorer.


Project Structure

openscad-api/
โ”œโ”€โ”€ main.js            โ† Electron entry point
โ”œโ”€โ”€ server.js          โ† Express REST API
โ”œโ”€โ”€ package.json       โ† scripts + electron-builder config
โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ index.html     โ† full web UI (HTML/CSS/JS + Three.js)
โ”œโ”€โ”€ setup-windows.ps1  โ† Windows installer (Node + OpenSCAD via winget)
โ”œโ”€โ”€ start.bat          โ† Windows launcher
โ””โ”€โ”€ build-exe.bat      โ† build Windows EXE

.github/workflows/
โ””โ”€โ”€ release.yml        โ† automatic build on tag push

Building Releases

Local

cd openscad-api
npm run dist           # Windows EXE (NSIS + Portable) โ†’ openscad-api/dist/
npm run dist:portable  # portable EXE only
npm run dist:all       # all platforms (Linux + macOS + Windows)

GitHub Actions

Push a tag โ†’ automatic build + release:

git tag v1.0.1
git push origin v1.0.1

Manual trigger: GitHub โ†’ Actions โ†’ "Build Windows EXE & Release" โ†’ Run workflow.


Tech Stack

Component Stack
Desktop framework Electron 31
Backend Node.js + Express
AI Claude (Anthropic API) with Vision
3D viewer Three.js + STLLoader
Syntax highlighting highlight.js
3D rendering OpenSCAD headless (--render)
Build electron-builder (NSIS, portable, dmg, AppImage)
UI Vanilla HTML/CSS/JS (single file)

License

MIT โ€“ free to use, modify, and use commercially.


Contributions Welcome

Pull requests and issues are very welcome. Ideas:

  • Better error handling for complex geometries
  • Open STL directly in PrusaSlicer / Bambu Studio
  • Before/after comparison for refinements
  • Batch generation from multiple photos
  • Export as STEP / OBJ
  • Code diff view during refinement

โค๏ธ Support / Donate

If openscad-vision saves you time on your next show, consider buying me a coffee:

Donate via PayPal

Donations are completely optional โ€” the app stays MIT-licensed and free either way. ๐Ÿ™Œ


Created with Claude Code

About

A native desktop app that uses Claude Vision to generate parametric OpenSCAD models from photos or text descriptions.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors