← Back to Projects

BrickVision

Turns ideas or 3D models into buildable LEGO-style instructions, making custom creations faster and more accessible.

Overview

BrickVision takes the friction out of creative building by converting either text prompts or 3D models into practical build plans. Instead of designing every layer by hand, users can start from an idea and quickly get a structured output they can iterate on. What makes it impressive is that it bridges imagination and execution in a very tangible way.

Demo

No live demo available for this project. See the repo for setup and run instructions.

Description

LegoBrain (brain.py) reads .config section [brain]: backend = mock, gemini, deepseek, openrouter, or nova; model overrides per provider (defaults include gemini-2.5-flash, DeepSeek chat, OpenRouter model IDs). Mock mode returns canned grids (tower, house, hollow_cube, horse, …). Live backends call the configured API with a “Master LEGO Architect” style system prompt; responses are stripped of markdown fences before grid extraction. API keys load from .env (GEMINI_API_KEY, DEEPSEEK_API_KEY, OPENROUTER_API_KEY).

Grid semantics and engine parse_grid splits on double newlines into 2D character layers. COLOR_MAP maps letters (e.g. X/Y yellow, R red, B blue, K black, W white) to LDraw color IDs. BRICK_PARTS fixes the catalog to Duplo-like stacking: 2×4 (3001), 2×2 (3003), 1×2 (3004), 1×1 (3005). A greedy layer optimizer places bricks; save_ldr emits absolute-positioned 1 lines with stud spacing (20 LDU) and 24 LDU layer height. Optional force_symmetry mirrors rows for symmetric builds. prefer_larger_bricks trades strict per-cell color for fewer, larger parts when enabled in CLI prompts.

3D mesh path voxelizer.py uses trimesh to load meshes, voxelize at a configurable pitch (default 1 stud), optionally binary_fill_holes via SciPy, and map occupied cells into letter grids. If part count exceeds ~10k, app.py increases pitch and re-voxelizes. [voxel] flip_forward_stems in .config lists model filename stems whose forward axis is flipped so GLB/glTF exports face the intended direction in LDraw viewers.

Artifacts and resources Prompt runs write the cleaned grid to generated_input/<prompt>.txt and the raw model transcript to raw_input/<prompt>.raw.txt for debugging. ldraw_build.py resolves data/parts.csv or resoruces/parts.csv and local LDraw libraries for validation; viewers need an external parts/ tree pointed at in LeoCAD or similar.

Project photos

Airbus

Prompt-to-LDraw example (Gemini), viewed in Stud.io.

F-22 Raptor

Prompt-to-LDraw example (Gemini), viewed in Stud.io.

Tank

Prompt-to-LDraw example (Gemini), viewed in Stud.io.

Implementation

Entry: python app.py with no args enters interactive prompt mode (optional CLI question for prefer_larger_bricks). Passing a mesh path runs the voxel pipeline; passing a text prompt string runs LegoBrain → outputs/<stem>.ldr.

Key modules: lego_engine.py — parse_grid, voxel_array_to_layers, count_parts, save_ldr; brain.py — LegoBrain.generate_grid_with_raw; voxelizer.py — load_and_voxelize with flip_forward; ldraw_build.py — standalone build helper with multi-path CSV discovery.

Tests: tests/ includes Gemini prompt regression tests, OpenRouter/DeepSeek wiring checks, and grid robustness (e.g. ragged rows guarded in placement).

Tech & tools

  • Python
  • Google Gemini
  • LDraw
  • NumPy
  • trimesh
  • SciPy
  • python-dotenv

Highlights

  • Pluggable LLM backends via .config + .env; default Gemini 2.5 Flash
  • Constrained brick catalog (3001–3005) with COLOR_MAP and LDraw placement math
  • Dual pipeline: prompt → grid → .ldr and mesh → voxel → grid → .ldr
  • Debug artifacts in generated_input/ and raw_input/; outputs/ only for LDR

More projects

tinyTemp

Custom tiny temperature monitor that evolved from an ATmega328P prototype into a compact ATtiny85 OLED PCB.

Award winning

WorldWide Rover

Award-winning internet-controlled rover that lets users drive and monitor a physical robot from anywhere in real time.

BareTag Tool Tracker

Smart tool tracking that helps teams instantly find equipment, prevent loss, and stay coordinated in real time.

Buffet

Automated trading system that tests strategies, learns from market behavior, and executes decisions with built-in risk controls.

HeadHunter

AI-powered job search assistant that helps people find better-fit roles faster, with smarter resume matching and cleaner tracking.

Meal Planner

Personal meal planning app that turns “what should I cook?” into a clear weekly routine with pantry awareness and shopping support.

Pong on Assembly

Classic Pong rebuilt from the ground up in hardware and low-level assembly, showing full-stack systems engineering in action.

Custom Single-Cycle 32-Bit Processor

From-scratch 32-bit processor design that brings core computer architecture concepts to life in working hardware.

ThreadLib Disk Scheduler

C++ user-level threading library paired with a concurrent disk scheduler that coordinates requester threads and SSTF service.

Multilateration 3D Positioning

3D location engine that estimates where an object is in space and validates accuracy through realistic simulation.

RISC-V Encryption

Encryption concepts implemented at the hardware-software boundary, showing security logic at instruction level detail.

PUF Tester

Hardware security testing toolkit for measuring unique device fingerprints and reliability under real test conditions.

tinyTemp

Custom tiny temperature monitor that evolved from an ATmega328P prototype into a compact ATtiny85 OLED PCB.

Award winning

WorldWide Rover

Award-winning internet-controlled rover that lets users drive and monitor a physical robot from anywhere in real time.