Skip to content

lbruand/bricksvg

Repository files navigation

ldr2svg

Convert architecture diagrams and LDraw brick scenes into clean, editable isometric SVG illustrations.

CI License Ruff ty Python

What it does

ldr2svg turns diagrams into isometric brick illustrations. Each node becomes a coloured 2×2 brick, clusters become raised platforms, and edges become arching arrows — all rendered as a single SVG you can edit in Inkscape, LibreOffice Draw, or drop straight into Google Slides.

Three input formats are supported:

Format Command Example
diagrams Python scripts diagram2svg uv run diagram2svg arch.py
Mermaid flowcharts (.mmd) mermaid2svg uv run mermaid2svg arch.mmd
LDraw / LeoCAD (.ldr) brick scenes ldr2svg uv run ldr2svg scene.ldr

Example transformation

Input — diagrams-library output Output — isometric brick SVG
diagrams-library cluster nesting diagram isometric LEGO brick rendering

Usage

diagrams-library script → SVG

uv run diagram2svg arch.py -o arch_bricks.svg

Mermaid flowchart → SVG

uv run mermaid2svg arch.mmd -o arch_bricks.svg

LDraw scene → SVG

uv run ldr2svg scene.ldr

Outputs scene.svg alongside the input file.

Requirements

System dependencies

Tool Purpose Install
OpenSCAD Render brick piece images sudo apt install openscad
Graphviz Lay out diagrams-library and Mermaid graphs (dot) sudo apt install graphviz
Xvfb Virtual display for headless OpenSCAD sudo apt install xvfb

On macOS: brew install openscad graphviz (Xvfb not needed).

Python

  • Python 3.10+
  • uv

Install

uv sync

Development

uv run pytest test/ -m "not slow"   # fast unit tests (no OpenSCAD needed)
uv run ruff check ldr2svg/ test/    # lint
uv run ty check ldr2svg/            # type check

Slow integration tests (require OpenSCAD; use xvfb-run on headless systems):

xvfb-run uv run pytest test/ -v

How to import your SVG into Google Slides

  1. Load the SVG into a LibreOffice presentation (tested on LibreOffice 24.2.7.2)
  2. Click the image → contextual menu → Break the SVG
  3. Save as .pptx (Microsoft PowerPoint 2007+)
  4. Upload the .pptx into Google Slides

Credits and licences

  • ldr2svg/brick.scad — derived from Thingiverse thing:5699, © 2015 Christopher Finke, MIT licence.

  • LDraw — part geometry and colour definitions follow the LDraw open standard for Brick CAD programs. LDraw™ is a trademark of the Estate of James Jessiman.

About

Turn (mermaid) diagrams into isometric 3D brick landscape

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors