Add BOSL (Belfry OpenSCAD Library) bindings for LuaCAD#5
Merged
Conversation
Add comprehensive bindings for all functions from the Belfry OpenSCAD Library (BOSL). Functions are accessible via the `bosl` namespace (e.g. `bosl.cuboid(...)`, `bosl.threaded_rod(...)`) and generate proper OpenSCAD code with automatic `include`/`use` directives on SCAD export. Covers all BOSL modules: shapes, transforms, masks, threading, paths, beziers, involute_gears, joiners, sliders, metric_screws, linear_bearings, nema_steppers, phillips_drive, torx_drive, wiring, quaternions, triangulation, convex_hull, debug, math, and constants. https://claude.ai/code/session_01LAjoXUcfTZ7QhrHKxz8Wa1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive Lua bindings for the BOSL (Belfry OpenSCAD Library), enabling LuaCAD users to access BOSL's extensive collection of 3D modeling functions directly from Lua scripts. All BOSL functions are registered under the
boslnamespace and automatically generate the required OpenSCADinclude/usedirectives.Key Changes
New BOSL module (
crates/luacad/src/bosl.rs):make_bosl_fn()factory to generate Lua closures that wrap BOSL function callsScadNode enum extension (
crates/luacad/src/scad_export.rs):BoslCallvariant to represent BOSL function/module calls in the ASTcollect_bosl_modules()to recursively scan the node tree and collect all referenced BOSL modulesgenerate_scad()to automatically emitinclude <BOSL/constants.scad>anduse <BOSL/...>directives based on actual usageBoslCallnodes to generate proper OpenSCAD syntaxLua engine integration (
crates/luacad/src/lua_engine.rs):register_bosl()Library exports (
crates/luacad/src/lib.rs):boslmoduleExample script (
examples/bosl_demo.lua):Implementation Details
[...], string keys become named parameterskey = valuehttps://claude.ai/code/session_01LAjoXUcfTZ7QhrHKxz8Wa1