A proof-of-concept tool that converts natural language descriptions of mechanical parts into valid OpenSCAD code.
The tool now supports three bracket types: L-brackets, flat plates, and 3-way corner brackets!
# Install dependencies
pip3 install anthropic
# Set your API key
export ANTHROPIC_API_KEY='your-api-key-here'Get your API key at: https://console.anthropic.com/
python3 bracket_gen.pyThen describe your bracket in natural language:
Description: L-bracket, 60mm wide, 80mm tall, M4 holes
Description: Flat mounting plate, 80x60mm, 4 corner holes
Description: Corner bracket for 3 surfaces, 60mm size
The tool will:
- Detect the bracket type from your description
- Parse dimensions and parameters with Claude
- Ask clarifying questions for missing details
- Validate the design
- Generate the OpenSCAD file
python3 test_example.py # Original L-bracket tests
python3 test_all_brackets.py # All bracket types (11 variants)This generates example brackets of all types to demonstrate functionality.
Two perpendicular flanges at 90 degrees:
- Base: Configurable width × depth × thickness
- Vertical flange: Configurable height × thickness
- Mounting holes: 2-4 on base, 0-N on vertical
- Corner fillet: For structural strength
- Use cases: Wall mounting, shelf brackets, equipment mounting
Single flat plate with flexible hole patterns:
- Dimensions: Configurable width × depth × thickness
- Hole patterns: Corners, grid, edge, or center
- Corner fillets: Optional (for rounded corners)
- Use cases: Adapter plates, mounting bases, spacers
Three-way bracket for internal corners:
- Size: Equal-sized flanges on all three planes
- Mounting holes: 2-4 per flange
- Fillets: Cylindrical + spherical at junction
- Use cases: Frame corners, box assembly, shelf supports
See BRACKET_TYPES.md for complete details on all bracket types.
- Install OpenSCAD
- Open the generated
.scadfile - Press F5 to preview or F6 to render
- Export as STL via File → Export → Export as STL
$ python3 bracket_gen.py
Description: I need a 50mm wide, 70mm tall L-bracket with M4 holes
PROCESSING WITH CLAUDE
========================
Confidence: HIGH
Interpretation: L-bracket with 50mm base width, 70mm vertical height,
M4 mounting holes (5mm clearance)
CLARIFICATION NEEDED
====================
The following details need clarification:
1. Base thickness not specified (affects structural strength)
2. Number of mounting holes on base (2 or 4)
3. Number of holes on vertical flange
Base Thickness [3mm]:
Fillet Radius [5mm]:
Hole Diameter [5mm]:
Base Hole Count [4]:
Vert Hole Count [2]:
Use square base (50mm x 50mm)? [Y/n]:
✓ Generated: l_bracket_50x70.scad
✓ File size: 1242 bytes
The script produces clean, well-commented OpenSCAD:
// L-Bracket Generated by Forge
// Dimensions: 50mm x 50mm base, 70mm height
// Designed for 3D printing with PLA/PETG
$fn = 50; // Circle resolution
module l_bracket() {
difference() {
union() {
// Base (horizontal flange)
cube([50, 50, 3]);
// Vertical flange
translate([0, 0, 3])
cube([50, 3, 70]);
// Corner fillet for strength
translate([0, 3, 3])
rotate([0, 90, 0])
cylinder(r=5, h=50);
}
// Subtract mounting holes from base
translate([10, 10, -5.0])
cylinder(d=5, h=13);
// ... more holes ...
}
}
l_bracket();- ✓ Natural language input parsing via Claude AI
- ✓ Automatic bracket type detection (L-bracket, flat plate, corner bracket)
- ✓ Dynamic dimension extraction from descriptions
- ✓ Interactive parameter refinement with sensible defaults
- ✓ Support for multiple screw sizes (M3, M4, M5, M6)
- ✓ Multiple bracket types:
- L-brackets (right-angle, 2 flanges)
- Flat plates (single plane, various hole patterns)
- Corner brackets (3-way, internal corners)
- ✓ Flexible hole patterns (corners, grid, edge, center)
- ✓ Configurable hole counts (2-4 base holes, 0-N vertical holes)
- ✓ Automatic fillet generation for structural strength
- ✓ Clean, commented OpenSCAD output
- ✓ Material hints in comments
- ✓ Comprehensive parameter validation
- Dimension sanity checks (min/max, positive values)
- Hole overlap detection
- Edge clearance validation
- Geometry consistency checks
- ✓ OpenSCAD syntax validation (if OpenSCAD installed)
- ✓ Detailed error messages with actionable feedback
- ✓ Extensible architecture (easy to add new bracket types)
- ✗ Fixed hole positioning for L-brackets (10mm from edges)
- ✗ No preview/visualization within the tool
- ✗ Requires OpenSCAD for viewing/rendering
- ✗ Limited bracket types (3 types currently)
- ✗ No T-brackets, hinges, or custom geometries yet
- ✅ Step 1: Hardcoded L-bracket generation
- ✅ Step 2: LLM integration with Claude API
- ✅ Step 3: Comprehensive validation layer
- ✅ Step 4: Multiple bracket types (L-bracket, flat plate, corner bracket)
- T-brackets
- U-channel brackets
- Custom hole patterns (user-defined positions)
- Configurable hole spacing/offset
- Support for countersunk holes
- Lightening pockets (material reduction)
- Text embossing (labels, version numbers)
- Multiple material presets with optimized settings
Forge/
├── bracket_gen.py # Main generator (LLM-powered, multi-type)
├── generators.py # Bracket type generators module
├── validator.py # Validation module
├── test_example.py # Original L-bracket tests
├── test_all_brackets.py # Multi-bracket test suite (11 variants)
├── test_validation.py # Validation test suite
├── README.md # This file
├── USAGE.md # Detailed usage guide
├── VALIDATION.md # Validation reference
├── BRACKET_TYPES.md # Bracket types reference
├── QUICKSTART.md # Quick reference
├── *.scad # Generated OpenSCAD files
└── test_*.scad # Test outputs (L-brackets, plates, corners)
- Pure OpenSCAD output: No custom geometry kernel needed
- Simple primitives: Uses only
cube(),cylinder(),translate(),rotate() - Readable code: Generated SCAD files include comments and consistent formatting
- Fillet approach: Uses cylindrical fillets for strength (could be enhanced with
hull())
- Script runs without errors
- Generates valid
.scadfiles - Parameterized generation works
- Multiple test cases pass
- OpenSCAD renders without errors (requires manual testing)
- STL export works (requires manual testing)
- Part is 3D printable (requires actual printing test)
- API key validation works
- Natural language parsing extracts dimensions correctly (needs live testing)
- Clarification questions are relevant (needs live testing)
- Default values are sensible
- Edge cases handled (missing dimensions, invalid input)
- Dimension validation works (13/13 tests passed)
- Hole overlap detection works
- Edge clearance validation works
- Negative value detection works
- Zero dimension detection works
- Geometry consistency checks work
- OpenSCAD syntax validation works (when OpenSCAD installed)
- Error messages are clear and actionable
- Warnings vs. errors are properly categorized
- Valid OpenSCAD code: Can it be rendered?
- Usability: Could a non-CAD-expert use the output?
- Quality: Is the output 3D printable?
- Correctness: Do dimensions match specifications?
The tool can understand various phrasings for all bracket types:
- "I need a 60mm wide, 80mm tall L-bracket with M4 holes"
- "Make me a right-angle bracket, 50x70mm with 4 mounting holes"
- "L-bracket for mounting a motor, 100mm base, 120mm height, M6 bolts"
- "Small bracket 40mm square base, 50mm vertical, M3 screws"
- "Flat mounting plate, 80x60mm, 4 corner holes"
- "Adapter plate, 100mm square, grid pattern with 9 holes"
- "Mounting base, 70x50mm, M5 holes at edges"
- "Spacer plate with rounded corners, 60mm, 4 holes"
- "Corner bracket for joining 3 surfaces, 60mm"
- "3-way bracket, 80mm, M6 holes"
- "Box corner reinforcement, 50mm size"
- "Internal corner bracket, 100mm, heavy duty"
The tool uses Claude Sonnet 4.5 for natural language processing. Typical costs:
- Input:
200 tokens per description ($0.0006) - Output:
100-200 tokens ($0.0015) - Total per bracket: ~$0.002 (less than 1 cent)
Status: Step 4 complete. Multiple bracket types implemented (L-bracket, flat plate, corner bracket). Next: Enhanced features and more bracket types.