Skip to content

solid_from_board: PCB to solid CAD part (inverse of board_from_solid)#425

Merged
ecto merged 1 commit into
mainfrom
claude/amazing-dijkstra-ecdqoz
Jul 7, 2026
Merged

solid_from_board: PCB to solid CAD part (inverse of board_from_solid)#425
ecto merged 1 commit into
mainfrom
claude/amazing-dijkstra-ecdqoz

Conversation

@ecto

@ecto ecto commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Adds solid_from_board, the inverse operation of board_from_solid. This tool materializes a PCB session as a solid CAD part by extruding the board outline (with cutouts preserved as interior holes) and optionally adding simplified component keep-out volumes. The substrate is assigned a homogenized FR4+copper density so that inspect_cad and physics simulations see the real board mass rather than bare FR4.

Key Changes

  • New tool solid_from_board (packages/mcp/src/tools/ecad.ts):

    • Extrudes board outline to thickness via hole-aware sketch path (cutouts become interior walls, no boolean pass needed)
    • Computes FR4 + copper mass from stackup and copper coverage (zones, traces, pads, vias)
    • Generates simplified component keep-out volumes: prefers kernel 3D body extents, falls back to courtyard × per-package-class default height
    • Injects into existing CAD session (document_id_target) or mints fresh session
    • Assigns homogenized density material so mass properties are realistic
    • Returns detailed mass breakdown, component part IDs, and optional inline document IR
  • Helper functions:

    • loopArea() — shoelace area of closed polygon
    • loopToSegments() — convert polygon to Sketch2D line segments
    • padAreaMm2() — copper area per pad shape
    • copperAreaByLayer() — per-layer copper coverage (zones, traces, vias, pads)
    • estimateBoardMass() — FR4 + copper mass from outline area and stackup
    • componentKeepouts() — generate keep-out boxes from 3D meshes or courtyard fallback
    • packageHeightMm() — default body height by package class (0402, SOIC, DIP, etc.)
  • Comprehensive test suite (packages/mcp/src/__tests__/solid-from-board.test.ts):

    • 58mm rotor board with bore and hub cutouts as reference geometry
    • Validates outline extrusion with cutouts intact (volume within 2%)
    • Verifies mass metadata against hand-computed FR4 + 2oz copper (within 5%)
    • Tests component keep-out volumes above board with plausible heights
    • Validates injection into existing CAD session (e.g., enclosure) and downstream check_enclosure_fit compatibility
    • Error handling for missing PCB and unknown target sessions
  • Server integration (packages/mcp/src/server.ts):

    • Registered as MCP tool with schema and description
    • Cross-session writer: reads PCB from document_id, writes CAD to document_id_target (or mints new)
    • Handles durable persistence and event logging for target session
  • Next-action hints (packages/mcp/src/tools/next-actions.ts):

    • Suggests render_view to visually cross-check the solid
    • Suggests inspect_cad to measure volume, bbox, and homogenized mass

Notable Implementation Details

  • Hole-aware extrusion: Uses multi-loop sketch (outline + cutouts as holes) so bore/cutout polygons survive as real interior walls without needing a boolean Difference pass.
  • Mass homogenization: Computes total FR4 + copper mass, then derives a single density for the extruded slab so that inspect_cad and physics engines read the correct mass off the material property.
  • Copper coverage estimation: Sums zone fill (hatched pours count half), trace/arc length × width, pad copper per layer, and via annular rings; each layer capped at board area to avoid double-counting overlaps.
  • Component fallback chain: Tries kernel 3D body extents first (exact XY + Z), falls back to courtyard/pad bbox extruded to package-class default height, skips mounting holes and NPTH-only footprints.
  • Response truncation: Component

https://claude.ai/code/session_01GepcQepAbbTJLcEzsK1f8X

The inverse of board_from_solid. A finished board can now appear in a
mechanical assembly (enclosure fit, motor stacks, clash/clearance checks,
mass properties) as real geometry instead of a dumb extruded disc:

- Substrate: the board outline extruded to its thickness through the
  hole-aware sketch path (#396), so bore/cutout polygons survive as real
  holes in one multi-loop solid — no boolean pass.
- Components: optional simplified keep-out volumes, one child part per
  placed footprint — kernel 3D body extents where available, else
  courtyard/pad bbox x a per-package-class default height, on the correct
  side of the board.
- Mass: FR4 volume + per-layer copper coverage (zones minus voids, traces,
  arcs, pads, via annular rings) x stackup copper thickness, attached as a
  homogenized density on the substrate material so inspect_cad and physics
  read the real FR4+copper mass off the solid.

Output injects into an existing CAD session (document_id_target) — with
explicit hydrate/persist handling since the central plumbing keys off the
read-only PCB source id — or mints a fresh session and echoes the IR for
open_document elsewhere.

Round-trip test: a 58mm rotor board (center bore + 4 hub holes, 2oz pours
both sides) extrudes to within 2% of area x thickness with cutouts intact,
mass lands within 5% of hand-computed FR4+Cu, and the injected solid
coexists with an enclosure in a check_enclosure_fit session.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GepcQepAbbTJLcEzsK1f8X
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vcad-mcp Ready Ready Preview, Comment Jul 7, 2026 2:28pm
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
mecheval Ignored Ignored Jul 7, 2026 2:28pm
vcad Ignored Ignored Jul 7, 2026 2:28pm
vcad-docs Ignored Ignored Jul 7, 2026 2:28pm

Request Review

@ecto
ecto merged commit faca0ae into main Jul 7, 2026
12 checks passed
@chojiai

chojiai Bot commented Jul 7, 2026

Copy link
Copy Markdown

What shipped

You can now convert a PCB design directly into a solid 3D part, completing the round-trip between circuit board and mechanical CAD. The board outline — including any cutouts like mounting holes or bore openings — is extruded to the correct thickness, and each placed component can be represented as a simplified keep-out volume. The resulting part carries accurate mass properties based on the actual FR4 substrate and copper content, so weight estimates and physics simulations reflect the real board rather than bare fiberglass.


Plain-English summary generated by Choji from this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants