Skip to content
 
 

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenBrick Parametric Brick Generator

What is this?

You know those little plastic building blocks with studs on top that everyone definitely doesn't call by a specific Danish trademark? Yeah, those. This makes parametric versions of them that you can 3D print.

Built in Godot 4 because why not. Real-time preview, STL export, and enough sliders to keep you busy for hours.

Features

  • Real-time 3D preview — tweak a slider, watch the brick morph. Instant gratification.
  • STL export — export one brick or a whole kit. Your slicer will thank you.
  • Parametric everything:
    • Width, length, height (in studs/plates, because that's how we measure things here)
    • Stud diameter, height, chamfer (yes, studs have chamfers now)
    • Wall thickness (thicc or thin, your call)
    • Anti-stud clearance and chamfer (the hole that receives the stud)
    • Clutch rib radius (for that satisfying click)
    • Horizontal play and axle play (tolerance is not just a personality trait)
  • Brick types: Brick, Tile, Jumper (the holy trinity)
  • FDM-optimized defaults — tuned for PETG because PLA is for cowards

Default Tolerances (for the PETG connoisseur)

Parameter Value What it does
Stud diameter 5.0 mm Slightly thicc to account for plastic shrinkage
Anti-stud clearance 0.15 mm How much room the stud has inside the tube
Wall rib radius 0.30 mm The little bumps that make things stay together
Clutch offset -0.15 Makes the anti-stud tubes thicker so they don't snap
Horizontal play 0.05 mm How much smaller the brick is than the math says it should be
Axle play 0.25 mm For when you want to put a technic axle through it

Getting Started

Using the pre-built executable

  1. Download the latest release for your platform from the Releases page
  2. Run the executable — no installation needed
  3. Click the + button to add a brick
  4. Fiddle with the sliders until it looks right
  5. Click Export Kit and feed the STL to your printer

Running from source

  1. Open the project in Godot 4.x (you have that installed, right?)
  2. Run the scene (Main.tscn)
  3. Click the + button like you mean it
  4. Fiddle with the sliders until it looks right
  5. Click Export Kit and feed the STL to your printer

Details

How brick generation works

The generator uses Godot's CSG (Constructive Solid Geometry) system to build bricks from primitive shapes. The entire pipeline lives in BrickGenerator.gd and is dispatched from the generate_brick() function.

Entry point: generate_brick()

This function calculates the brick's outer dimensions based on parameters:

tw = (width × pitch) - (2 × horizontal_play)
tl = (length × pitch) - (2 × horizontal_play)
th = height_in_plates × plate_h
  • pitch = 8.0 mm (center-to-center stud distance)
  • plate_h = 3.2 mm (height of one plate)
  • horizontal_play shrinks the brick slightly so it fits between adjacent studs

It then creates a CSGCombiner3D node and calls _build_dispatch(), which routes to the appropriate builder based on the brick type.

Brick types and their builders

_build_standard_brick() — Used for the "brick" type:

  1. Creates the outer shell via _add_rounded_solid() — a box with rounded corners (radius 0.8 mm)
  2. Creates the inner cavity via another _add_rounded_solid() with is_subtractive = true — a smaller box hollowed out from the inside
  3. The cavity height is th - wall_t (wall thickness subtracted from total height)
  4. Calls _add_clutch_ribs() to add friction ribs on the inner walls
  5. Calls _add_clutch_posts() to place anti-stud tubes on the bottom
  6. Calls _add_smart_studs() to place studs on the top surface

_build_tile() — Used for the "tile" type:

Same as brick but does not call _add_smart_studs() — tiles have no studs on top. The top surface is flat.

_build_jumper() — Used for the "jumper" type:

Calls _build_tile() first (flat base with anti-studs), then calls _add_smart_studs() with custom stud placement controlled by jumper_studs_w, jumper_studs_l, jumper_offset_x, jumper_offset_z, and jumper_stud_rotation. This allows placing a subset of studs at arbitrary positions — useful for half-stud offsets.

The grid system

The entire brick geometry is based on an 8 mm grid:

  • Studs are placed at (x + 0.5) × pitch for x in range(width), centered around the brick origin
  • Anti-studs are placed at (x + 1) × pitch for x in range(width - 1), centered at the midpoints between studs
  • This means the anti-stud grid is offset from the stud grid by half a pitch (4 mm)

For a 2×2 brick:

  • Studs at (-4, -4), (-4, 4), (4, -4), (4, 4)
  • Anti-stud at (0, 0) — one tube in the center, surrounded by 4 studs

For a 4×4 brick:

  • Studs at (-12, -12), (-12, -4), ..., (12, 12) — 16 studs
  • Anti-studs at (-8, -8), (-8, 0), (-8, 8), (0, -8), (0, 0), (0, 8), (8, -8), (8, 0), (8, 8) — 9 tubes in a 3×3 grid

Anti-stud geometry: _add_anti_stud_geometry()

Each anti-stud is a hollow tube created with CSGPolygon3D in MODE_SPIN:

  1. Outer tube: A rectangle spun around the Y axis — radius = (6.51 - clutch_offset) / 2, height = cavity height
  2. Inner hole: A slightly narrower rectangle subtracted from the tube — radius = (stud_d + anti_stud_clearance) / 2
  3. Bottom chamfer: The inner hole is flared at the bottom (0.5 mm wider at the opening) to guide studs in smoothly

The wall thickness of the anti-stud tube is:

wall = (6.51 - clutch_offset) / 2 - (stud_d + anti_stud_clearance) / 2

With defaults: wall = (6.51 + 0.15) / 2 - (5.0 + 0.15) / 2 = 3.33 - 2.575 = 0.755 mm

Clutch mechanics

Wall ribs (_add_clutch_ribs()): Small vertical half-cylinders on the inner surfaces of the outer walls. These press against the studs of the brick below, providing lateral grip. Rib radius is controlled by wall_rib_radius (default 0.30 mm).

Anti-stud grip: The inner diameter of the anti-stud tube is slightly smaller than the stud diameter, creating an interference fit. The effective grip depends on:

  • stud_d — how big the stud is
  • anti_stud_clearance — how much larger the anti-stud hole is than the stud
  • PETG hole closure — printed holes tend to be ~0.3 mm smaller than designed, which effectively increases the interference

Between anti-studs: On larger bricks, the outer walls of adjacent anti-stud tubes form pockets that can grip studs laterally. The interference depends on:

  • Tube outer radius: (6.51 - clutch_offset) / 2
  • Stud radius: stud_d / 2
  • Distance from stud center to tube center: √(4² + 4²) ≈ 5.657 mm
  • Interference per side: tube_radius + stud_radius - 5.657

Tolerance interactions

  • horizontal_play: Shrinks the entire brick by 2 × horizontal_play in width and length. Makes the brick fit between adjacent studs without binding.
  • clutch_offset: Enlarges the anti-stud tube outer diameter (negative values = larger tubes). Also affects the 1×N solid rib size: (3.2 - clutch_offset) / 2.
  • anti_stud_clearance: Added to stud_d to determine the inner hole of the anti-stud tube. Positive = looser, negative = tighter.
  • wall_rib_radius: Controls how far the clutch ribs protrude from the inner walls. Larger = more lateral grip, but can make assembly too tight.

Stud geometry: _add_chamfered_stud()

Studs are created with CSGPolygon3D in MODE_SPIN with a chamfered profile:

  • Base: full stud diameter (stud_d)
  • Top: reduced by CHAMFER (0.25 mm) for a beveled edge
  • Height: stud_h (1.8 mm)

The chamfer helps the stud enter anti-studs smoothly and gives that authentic tapered look.

Why PETG needs different tolerances than PLA

PETG behaves differently from PLA when 3D printed:

  • Hole closure: Internal holes print ~0.3 mm smaller than designed. A 5.3 mm hole becomes ~5.0 mm actual.
  • Stud accuracy: Studs print close to designed size (within 0.05-0.1 mm).
  • Flexibility: PETG is stiffer than PLA, so interference fits need tighter clearances to avoid cracking.

This is why anti_stud_clearance is set to 0.15 mm (the hole is designed 0.15 mm larger than the stud, but prints ~0.15 mm smaller — creating a net interference fit), and clutch_offset is negative (to thicken the anti-stud walls so they don't snap under the interference).

Requirements

  • A computer (tested on a Dell Latitude with 8 GB RAM and no dedicated GPU — it runs)
  • Time (brick tuning is a journey, not a destination)
  • A 3D printer (or a friend with one)
  • A slicer that supports STL files (they all do)
  • Patience (first layer calibration is not optional)

Printing Tips

  • Material: PETG (tested with Sunlu, but don't blame us if your knockoff filament sucks)
  • Nozzle: 0.4 mm (standard issue)
  • Layer height: 0.1 mm (we like detail)
  • Temperature: 235-245°C (your mileage may vary, adjust accordingly)
  • Bed temp: 70-80°C (hot enough to stick, not hot enough to burn)
  • Cooling: 30-50% fan (PETG doesn't need a hurricane)

Credits

  • Wojciech Swat — Idea, execution, testing
  • Fayez Akhtar — UI design and implementation
  • The open source Godot community for making this possible

License

AGPL-3.0

Disclaimer

This project is a parametric 3D model generator for interoperability with construction toy systems. It is not affiliated with, endorsed by, or connected to any construction toy brand. All trademarks are property of their respective owners.

About

Basic parametric generation of standardized bricks

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages