$npx -y skills add rawwerks/VibeCAD --skill build123dCAD modeling with build123d Python library. Use when creating 3D models, exporting to GLB/STEP/STL, or doing boolean operations (union, difference, intersection). Triggers on: CAD, 3D modeling, sphere, box, cylinder, mesh export, GLB, STEP, STL, solid modeling, parametric design,
| 1 | # build123d CAD Modeling |
| 2 | |
| 3 | ## Zero-Setup with uv |
| 4 | |
| 5 | No installation required. Run any build123d script with: |
| 6 | |
| 7 | ```bash |
| 8 | uvx --from build123d python script.py |
| 9 | ``` |
| 10 | |
| 11 | This automatically downloads build123d and runs your script. First run takes ~30s, subsequent runs are instant. |
| 12 | |
| 13 | **Install uv** (if not already installed): |
| 14 | ```bash |
| 15 | curl -LsSf https://astral.sh/uv/install.sh | sh |
| 16 | ``` |
| 17 | |
| 18 | ## Critical: Imports |
| 19 | |
| 20 | All exports are in the **main module**: |
| 21 | |
| 22 | ```python |
| 23 | from build123d import Sphere, Box, Cylinder, export_gltf, export_step, export_stl |
| 24 | ``` |
| 25 | |
| 26 | **NEVER** use `from build123d.exporters import ...` - this module does not exist. |
| 27 | |
| 28 | ## Quick Start Example |
| 29 | |
| 30 | ```python |
| 31 | #!/usr/bin/env python3 |
| 32 | from build123d import Sphere, Box, export_gltf, Pos |
| 33 | |
| 34 | # Create shapes |
| 35 | sphere = Sphere(radius=20) |
| 36 | box = Pos(15, 0, 0) * Box(10, 10, 10) |
| 37 | |
| 38 | # Boolean union |
| 39 | result = sphere + box |
| 40 | |
| 41 | # Export to GLB (for web viewers, Three.js) |
| 42 | export_gltf(result, "./model.glb", binary=True) |
| 43 | print("Exported model.glb") |
| 44 | ``` |
| 45 | |
| 46 | Run it: |
| 47 | ```bash |
| 48 | uvx --from build123d python my_model.py |
| 49 | ``` |
| 50 | |
| 51 | ## Geometry Inspection (Optional) |
| 52 | |
| 53 | To inspect geometry properties, add this to your script: |
| 54 | |
| 55 | ```python |
| 56 | def inspect(shape): |
| 57 | bbox = shape.bounding_box() |
| 58 | print(f"Size: {bbox.max.X - bbox.min.X:.1f} x {bbox.max.Y - bbox.min.Y:.1f} x {bbox.max.Z - bbox.min.Z:.1f}") |
| 59 | print(f"Volume: {shape.volume:.1f}") |
| 60 | print(f"Faces: {len(shape.faces())}, Edges: {len(shape.edges())}") |
| 61 | |
| 62 | inspect(result) |
| 63 | ``` |
| 64 | |
| 65 | A full inspection harness is available in `scripts/harness.py` for advanced use. |
| 66 | |
| 67 | ## Quick Reference |
| 68 | |
| 69 | ### Shapes |
| 70 | ```python |
| 71 | Box(length, width, height) |
| 72 | Sphere(radius=20) |
| 73 | Cylinder(radius=10, height=25) |
| 74 | Cone(bottom_radius=15, top_radius=5, height=20) |
| 75 | Torus(major_radius=20, minor_radius=5) |
| 76 | ``` |
| 77 | |
| 78 | ### Boolean Operations |
| 79 | ```python |
| 80 | union = shape1 + shape2 # Fuse |
| 81 | difference = shape1 - shape2 # Cut |
| 82 | intersection = shape1 & shape2 # Common volume |
| 83 | ``` |
| 84 | |
| 85 | ### Positioning |
| 86 | ```python |
| 87 | from build123d import Pos, Rot |
| 88 | moved = Pos(x, y, z) * shape # Translate |
| 89 | rotated = Rot(rx, ry, rz) * shape # Rotate (degrees) |
| 90 | ``` |
| 91 | |
| 92 | ### Export |
| 93 | ```python |
| 94 | export_gltf(shape, "./out.glb", binary=True) # GLB for web |
| 95 | export_step(shape, "./out.step") # CAD interchange |
| 96 | export_stl(shape, "./out.stl") # 3D printing |
| 97 | ``` |
| 98 | |
| 99 | ## Examples by Capability |
| 100 | |
| 101 | 21 runnable examples in `references/examples/`: |
| 102 | |
| 103 | ### Basics (01-08) |
| 104 | - `01_simple_shapes.py` - Box, Sphere, Cylinder, Cone, Torus |
| 105 | - `02_boolean_operations.py` - Union (+), difference (-), intersection (&) |
| 106 | - `03_export_formats.py` - GLB, STEP, STL, BREP export |
| 107 | - `04_positioning.py` - Pos(), Rot() transforms |
| 108 | - `05_sketch_extrude.py` - 2D sketch to 3D solid |
| 109 | - `06_fillet_chamfer.py` - Edge rounding and beveling |
| 110 | - `07_csg_classic.py` - Classic CSG operations |
| 111 | - `08_hole_pattern.py` - GridLocations for hole patterns |
| 112 | |
| 113 | ### 3D Operations |
| 114 | - `loft.py` - Connect multiple profiles |
| 115 | - `vase.py` - **Revolve** + edge filtering + shelling |
| 116 | - `tea_cup.py` - Revolve + **sweep** for handle |
| 117 | |
| 118 | ### Advanced Techniques |
| 119 | - `roller_coaster.py` - **Helix** + Spline curves |
| 120 | - `packed_boxes.py` - **pack()** algorithm |
| 121 | - `toy_truck.py` - **Joints** for assembly |
| 122 | - `dual_color_3mf.py` - Multi-color 3MF export |
| 123 | |
| 124 | Run any example: |
| 125 | ```bash |
| 126 | uvx --from build123d python references/examples/01_simple_shapes.py |
| 127 | ``` |
| 128 | |
| 129 | ## Advanced Patterns |
| 130 | |
| 131 | For builder mode, edge filtering, loft, sweep, revolve: |
| 132 | See `references/advanced-patterns.md` |
| 133 | |
| 134 | ## bd_warehouse - Parametric Parts Library |
| 135 | |
| 136 | For threads, fasteners, simple gears, pipes, flanges, and bearings: See `references/bd-warehouse-reference.md` |
| 137 | |
| 138 | ```bash |
| 139 | uvx --from build123d --with bd_warehouse python script.py |
| 140 | ``` |
| 141 | |
| 142 | Examples: `09_bd_warehouse_threads.py` through `14_bd_warehouse_bearings.py` |
| 143 | |
| 144 | ## gggears - Advanced Gear Generation |
| 145 | |
| 146 | For advanced parametric gears (spur, helical, bevel, planetary, cycloid, racks): See `references/gggears-reference.md` |
| 147 | |
| 148 | ```bash |
| 149 | uvx --from build123d --with "gggears @ git+https://github.com/GarryBGoode/gggears" python script.py |
| 150 | ``` |
| 151 | |
| 152 | Examples: `15_gggears_spur.py` through `20_gggears_rack.py` |
| 153 | |
| 154 | **Quick example:** |
| 155 | ```python |
| 156 | from gggears import SpurGear, UP |
| 157 | from build123d import export_gltf |
| 158 | |
| 159 | gear1 = SpurGear(number_of_teeth=12, module=2.0, height=10.0) |
| 160 | gear2 = SpurGear(number_of_teeth=24, module=2.0, height=10.0) |
| 161 | gear1.mesh_to(gear2, target_dir=UP) |
| 162 | |
| 163 | assembly = gear1.build_part() + gear2.build_part() |
| 164 | export_gltf(assembly, "./gears.glb", binary=True) |
| 165 | ``` |
| 166 | |
| 167 | ## Post-Processing Pipeline |
| 168 | |
| 169 | After exporting GLB, you ca |