Skip to content

fix(parametric): generate proper threaded geometry for screws/bolts#143

Open
zachdive wants to merge 2 commits into
masterfrom
eve/fix-42-screws-threads
Open

fix(parametric): generate proper threaded geometry for screws/bolts#143
zachdive wants to merge 2 commits into
masterfrom
eve/fix-42-screws-threads

Conversation

@zachdive
Copy link
Copy Markdown
Contributor

@zachdive zachdive commented May 6, 2026

Summary

Closes #42.

When the model generated a screw or bolt, the threaded region rendered as smooth cylinder or blank space, and the same gap shipped through to the STL export. Root cause: the LLM was hand-rolling threads with bare `cylinder()` / `linear_extrude()`, neither of which can represent helical thread geometry in OpenSCAD. At the default low `$fn`, the thread profile collapses into invisible slivers.

Fix

Adds explicit guidance + one worked example to the parametric-chat system prompt directing the model to use BOSL2 for any threaded fastener:

  • `include <BOSL2/std.scad>` + the relevant module file (`screws.scad` for headed fasteners, `threading.scad` for plain threaded rod)
  • Generate threaded geometry with `screw()`, `screw_hole()`, `threaded_rod()`, `nut()`, etc. — never bare primitives
  • Set `$fn = 64` (96–128 for larger diameters) so threads actually resolve
  • Expose diameter / length / pitch as snake_case parameters
  • Use the BOSL2 spec string (`"M6x1"`, `"new images #8-32"`) so pitch is auto-picked

BOSL2 is already preloaded in the runtime (referenced from the README as a built-in library), so no library plumbing change is needed — only the prompt.

Test plan

  • Manual: run "M8 hex bolt 30mm long" through the parametric chat — should now produce a model with visible helical threads (no blank gap), exportable to STL.
  • Spot-check existing requests for nuts and threaded rods.

Suggested test prompts:

  • `an M6 hex bolt 25mm with matching nut`
  • `a threaded rod 8mm diameter 100mm long, 1.25mm pitch`
  • `a plate with four M3 tapped holes`

Notes

This is a pure prompt change; no runtime, library, or schema changes. The change is in `supabase/functions/parametric-chat/index.ts` only.

Authored by Eve (Zach's AI agent) on behalf of Adam.


Summary by cubic

Fixes missing/blank threads by requiring BOSL2 for all screws, bolts, nuts, threaded rods, and tapped holes, and removing boolean thread overrides so models and STL exports render correct helical threads (fixes #42).

  • Bug Fixes
    • Enforce BOSL2 includes and modules (std.scad, screws.scad, threading.scad); call screw(), screw_hole(), threaded_rod(), nut().
    • Remove boolean thread flags; use size strings like "M6x1" or "new images #8-32" and thread_len only for partial threads.
    • Forbid bare cylinder()/linear_extrude(); set $fn >= 64 (96–128 for larger diameters).
    • Add a minimal M8 hex bolt example.

Written for commit 5458cd3. Summary will update on new commits.

…rs (#42)

Threaded fasteners were rendering as smooth cylinders or blank space because
the model used bare cylinder()/linear_extrude() — OpenSCAD primitives can't
represent helical thread geometry. The thread region collapses to invisible
slivers, especially at default low $fn values, and the same blank space ships
through to the STL export.

Adds explicit guidance + a worked example to the parametric-chat system prompt
telling the model to:

- include <BOSL2/std.scad> + screws.scad / threading.scad
- use screw(), screw_hole(), threaded_rod(), nut() etc instead of cylinder()
- set $fn=64 (96-128 for larger diameters) so threads actually resolve
- expose diameter/length/pitch as snake_case parameters
- pass standard size strings like "M6x1" or "#8-32" so pitch is auto-picked

Closes #42

Authored by Eve (Zach's AI agent) on behalf of Adam.

Co-authored-by: eve-app <280557408+eve-app@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

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

Project Deployment Actions Updated (UTC)
cadam Ready Ready Preview, Comment May 11, 2026 11:48pm

Request Review

@supabase
Copy link
Copy Markdown

supabase Bot commented May 6, 2026

This pull request has been ignored for the connected project sgprnbvihmydyrzvkcir due to reaching the limit of concurrent preview branches.
Go to Project Integrations Settings ↗︎ if you wish to update this limit.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@zachdive zachdive marked this pull request as ready for review May 6, 2026 00:34
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 6, 2026

Greptile Summary

This PR is a pure system-prompt change that steers the LLM away from bare cylinder()/linear_extrude() primitives toward BOSL2 modules (screw(), screw_hole(), threaded_rod()) for any threaded fastener request, fixing blank/smooth thread geometry in generated models and STL exports.

  • Adds a "Threaded Fasteners (CRITICAL)" rule block covering required includes, banned primitives, $fn floor, snake_case parameter exposure, and the BOSL2 spec-string convention.
  • Appends a worked M8 hex bolt few-shot example that the LLM can directly copy; critically, thread=true is absent — the bolt call is screw(bolt_spec, head=\"hex\", length=bolt_length) with no pitch override, so standard M8x1.25 geometry is produced correctly.
  • No runtime, library, or schema changes; only the prompt string in supabase/functions/parametric-chat/index.ts is touched.

Confidence Score: 5/5

Safe to merge — pure prompt change with no runtime or schema impact, and the thread=true correctness issue from earlier review rounds is not present in this version.

The only change is the system-prompt string in a single Edge Function. BOSL2 guidance is technically accurate: includes are correct, the right modules are called, the previously-flagged thread=true boolean is gone, and $fn = 96 is appropriate for M8. The one finding is a naming nit in the worked example with no effect on runtime correctness.

No files require special attention.

Important Files Changed

Filename Overview
supabase/functions/parametric-chat/index.ts Adds BOSL2 threading guidance block and worked M8 bolt few-shot example to the system prompt. The thread=true bug from the previous review iteration is not present; inline and worked examples both call screw() without a thread argument. Minor: bolt_spec abbreviation contradicts the project naming rule baked into the same prompt.

Reviews (3): Last reviewed commit: "fix(parametric): remove boolean thread o..." | Re-trigger Greptile

Comment thread supabase/functions/parametric-chat/index.ts Outdated
Comment thread supabase/functions/parametric-chat/index.ts Outdated
@zachdive zachdive marked this pull request as draft May 6, 2026 00:53
@zachdive zachdive marked this pull request as ready for review May 7, 2026 23:42
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

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.

screws/bolt issues

1 participant