Skip to content

Single place to convert your 2D floor plans to 3d model (no LLM)

Python
17.2 KB
Raw Blame

PlanTo3D

tests

Floor plan PDF in. Furnished, walkable 3D house out. No AI model and no LLM: every step is geometry, rules and Blender.

Walking through the house built from the sample plan

Shown at 2× speed. Watch the full video (MP4, 28 s), recorded with the walkthrough's own Record button.

Upload Review the detected plan
Home page Review page
Top view Map (press M)
Top view Map

All screenshots show examples/sample_plan.pdf, a made-up drawing that ships with the repository.

How it works

flowchart LR
    A["Plan PDF (CAD export)"] --> B["detect.py: walls, doors, windows, rooms, stairs, scale"]
    B --> C["Review page: fix anything misread"]
    C --> D["furnish.py: furniture by rules"]
    D --> E["Blender: gen.py builds, bake.py bakes light"]
    E --> F["house.glb and light maps"]
    F --> G["Browser: walk, top view, map, record, screenshot"]
    E --> H["house.blend zip download"]
Step File Method
Read the PDF vector.py pdftocairo -svg for every line, curve and fill; pdftotext -bbox for words and positions
Walls detect.py Pairs of parallel lines in the heaviest grey pen. Evenly spaced families (tiles, stair treads, glass) are rejected. Filled squares touching a wall are columns
Scale detect.py Distance between the walls around a room label against the size written in it (14'x12'8"); the most common value wins
Openings detect.py Glass lines inside a wall band make a window. A gap with a swing arc is a door; a bare gap up to 4.6 ft is a door only if a line is drawn across it
Rooms detect.py Flood fill between walls and openings, split along single drawn lines, named from the labels (BED, TOI, KIT, DRG…)
Stairs, storeys detect.py Runs of evenly spaced treads next to UP / DN; separate wall clusters on a sheet are separate storeys, ordered by their titles
Furniture furnish.py Rules per room type: bed on the longest free wall, WC and basin by the door, L-shaped kitchen with the sink under the window, sofa facing a TV wall. Items keep clear of doors, windows and each other
3D blender/gen.py Walls with openings cut, sills and lintels, frames and glass, floors per room type, stairs, roof with parapet, site with road and trees
Lighting blender/bake.py Cycles bakes direct and bounced light into one light map per storey. The browser multiplies textures by it: no real-time lights, so it runs on any GPU
Viewer web/view.js three.js, unlit materials, wall collision, stairs between storeys

Quick start

Needs Python 3 (developed on 3.14), Node 18+ (22+ for the browser test), Blender 4.2+ and poppler (apt install poppler-utils or brew install poppler).

git clone <this repo> && cd planto3d
./run.sh                         # installs three.js, serves http://127.0.0.1:8080

Open the page. It checks Blender, the PDF tools, the viewer library and the materials, and accepts a plan only when all four are in place. The textures and models (about 150 MB, CC0, from Poly Haven) are not in the repository: press Download materials on the page, or run python3 fetch_assets.py.

Then press Try the sample plan, or drop your own PDF on the page.

macOS

brew install python node poppler
brew install --cask blender
export BLENDER=/Applications/Blender.app/Contents/MacOS/Blender     # Blender is not on PATH on a Mac
./run.sh

Windows

Install Python, Node.js, Blender and poppler (winget install oschwartz10612.Poppler, or choco install poppler), then in PowerShell:

npm install
$env:BLENDER = "C:\Program Files\Blender Foundation\Blender 4.5\blender.exe"    # your Blender version's folder
python server.py

pdftocairo must be found on PATH; the home page tells you if it, or Blender, is missing. The project was developed and tested on Linux; the macOS and Windows steps have not been run.

./run.sh --port 9000 --host 0.0.0.0     # reachable from other devices
./run.sh --cors https://your-site.com   # let another site call the API

What you get

Review before building Detected walls, doors, windows and rooms drawn over your PDF. Click to change or delete, draw walls, add doors and windows, set the scale
Interior themes Pick a theme on the review page: Contemporary (the look PlanTo3D always built), Minimalist, Royal (a European palace) or Rustic farmhouse. A theme sets the furniture, the decor (chandeliers, paintings, mirrors, an armchair, a clock or shelves, a bench at the foot of the bed), the colours of wood, fabrics, curtains, rugs and kitchen, and the floors and walls. Saved in the plan as theme
Your own themes See and make themes shows every theme's pieces as real renders. Make your own from any theme: choose each piece from the library of scanned models or the built-in ones, or use your own .glb, and set the colours and floors
Floor finish and wall paint Pick a room's floor (marble, wood, parquet, tiles, bathroom tiles, terracotta, concrete; Auto follows the theme, then the room type) and one wall colour for the house. Saved in the plan as room.floor and wall_color (#rrggbb); both win over the theme
Furniture on or off Untick Furniture for empty rooms
Move your furniture The Furniture tool on the review page shows each item: drag to move, turn it 90°, delete it, or add one from the list
Time estimate The build box shows about how long is left, learned from earlier builds on the same machine
Walkthrough W A S D and mouse on desktop, two thumbs on a phone. Starts at the entrance side of the plan
VR headset On a headset (Meta Quest and others with WebXR) the VR button shows up: the left stick walks where you look, the right stick turns in 30° steps, and your real height and head moves are used. Same walls and stairs as on screen. The browser allows VR only on https:// pages or localhost: put the Website zip on any https host, or on a Quest over USB run adb reverse tcp:8080 tcp:8080 and open http://localhost:8080
Top view (T) The house from above, one storey at a time
Map (M) Room names, stairs, where you stand and look; the big map adds each room's size and area
Measure (N) Click or tap two points on the house for the distance in metres and feet-inches (drag to look around meanwhile); works in top view too. The line and label are drawn in the 3D view, so screenshots and recordings show them
Finishes (F) Try another wall colour, or another floor for the room you stand in, straight away in the walkthrough. Save for the next build writes it into the plan; the light is baked for the old finish until you build again. Houses built before this feature can change only the wall colour
Screenshot (P) PNG of about 4K size
Record (R) Video of your walk as MP4 (browsers that record WebM are converted on the server; needs ffmpeg)
Tour (G) Walks itself from the entrance through every room and up the stairs, looks around in each, and records it as one video. Any key or click stops it
Sample plan, delete "Try the sample plan" on the home page; every plan in the list has Delete
Quantities A printable sheet from the review page or the walkthrough: floor area per finish, wall paint (less doors and windows), ceiling, toilet wall tiles, a door and window schedule with sizes, and a furniture count. In m² and sq ft
Blender file The house as one .blend with every texture packed inside, in a zip
Website The walkthrough as a static website in a zip, to share without this server (see below)

Interior themes

The same living room in Minimalist, Royal and Rustic farmhouse

The sample plan's living room in Minimalist, Royal and Rustic farmhouse, as the walkthrough shows it.

The Themes page
Themes page

Most theme furniture is real scanned models from Poly Haven (CC0): the carved four-poster bed, chandeliers, gilded mirror and grandfather clock of Royal, the painted farmhouse cabinets and settee of Rustic, the oak side tables and globe lamps of Minimalist. Pieces Poly Haven does not have (the minimalist platform bed and wardrobe, the royal armoire and turned-leg table, the farmhouse bed and plank table) are drawn by blender/gen.py from photo textures. Where a model does not fit a room, the furniture rules use the built-in piece in the theme's colours instead.

Which renderer does what. The walkthrough runs in the browser with three.js. Its light and shadows are computed once by Blender's Cycles engine and baked into light maps, so walking is smooth on any GPU but reflections and glossy highlights are not shown.

Build time and accuracy

Measured on a laptop with an RTX 3050 (4 GB).

One-storey house Draft High quality
Build + light bake about 1.5 min about 5 min
Light map of the storey 2048 px 4096 px

Detector scores on two real CAD drawings that were measured by hand (the drawings are private and not included):

Plan Walls: precision / recall Doors found Windows found Room types right
Two-storey house, ground floor 0.88 / 0.97 100% 100% 100%
Two-storey house, first floor 0.92 / 0.99 100% 100% 100%
Single floor of flats 0.94 / 0.97 93% 100% 100%

The sample drawing is read exactly: 18 walls, 5 doors, 5 windows, 5 rooms.

Put it on your own site

The walkthrough is a page you can place in an <iframe>, and every step is an HTTP call.

sequenceDiagram
    participant S as Your page
    participant P as PlanTo3D server
    S->>P: POST /api/upload with the PDF
    P-->>S: job id
    loop until stage is detected
        S->>P: GET /api/jobs/ID
    end
    S->>P: POST /api/jobs/ID/build with quality
    loop until stage is done
        S->>P: GET /api/jobs/ID
        P-->>S: stage, progress, eta_left
    end
    S->>S: show the walkthrough page in an iframe
<iframe src="https://your-planto3d-host/web/view.html?job=JOB_ID&embed"
        style="width:100%;aspect-ratio:16/9;border:0" allow="fullscreen; xr-spatial-tracking"></iframe>

examples/embed.html is a complete working page: upload, build, show.

Call Does
GET /api/system What is installed: { ready, blender, pdf_tools, viewer, materials }
POST /api/upload Body: the PDF. Header X-Filename. Returns { id } and starts detection
GET /api/jobs/{id} { stage, progress, message, floors, eta_left, elapsed, eta, outdated }. Stages: detecting, detected, queued, building, done, failed. eta (seconds per quality) before a build; outdated when the house was built before the build last changed
GET /jobs/{id}/plan.json The detected plan (feet): walls, openings, rooms, stairs per storey
POST /api/jobs/{id}/plan Save an edited plan. "furnish": false builds empty rooms. A floor's items list (furniture placed on the review page) replaces the rules for that floor
GET /api/jobs/{id}/quantities Areas in sq ft from the saved plan: { floors: [{ rooms: [{ name, finish, area, paint, tiles }] }], finishes, paint, ceiling, tiles, openings, furniture }. /web/quantities.html?job={id} shows it as a page
GET /api/jobs/{id}/furniture { floors, catalog }: each floor's furniture items (its own items, else the rules' choice) and the items that can be added
POST /api/jobs/{id}/build Body { "quality": "draft" | "high" }. Builds run one at a time
POST /api/jobs/{id}/export Packs the Blender file. Returns { url } of the zip
POST /api/jobs/{id}/site Packs the walkthrough as a static website. Returns { url } of the zip
GET /web/view.html?job={id} The walkthrough. &embed hides the link back to the upload page
GET /web/edit.html?job={id} The review page
GET /api/jobs The 30 most recent plans
DELETE /api/jobs/{id} Delete a plan and its house
GET /api/themes The themes: built-in and your own, with their pieces, colours, floors and pictures, and what each piece may be
POST /api/themes Make your own theme: { label, slots, colours, floors, wall, tv }; returns { id }. POST /api/themes/{id} changes it, DELETE removes it
POST /api/themes/{id}/model/{slot} Your .glb for one piece of your own theme; DELETE goes back to the built-in piece

To let people correct the plan first, show /web/edit.html?job={id} in the iframe instead of building straight away.

Share the walkthrough without the server

The server has no login, so do not open it to the internet for clients. Instead press Website in the walkthrough (or POST /api/jobs/{id}/site): the zip holds the viewer, the three.js files it needs and the house, nothing else (not the PDF, not the plan). Unzip it onto any static host (Netlify, GitHub Pages, your own web server) and send the link. To try it locally, run python3 -m http.server in the unzipped folder; opening index.html straight from the disk does not load the viewer's modules. Recordings there are saved as the browser makes them (MP4 or WebM).

Project layout

server.py          web server: the HTTP routes (standard library only)
jobs.py            a plan's job folder, the build queue, exports
theme_store.py     your own themes and the pictures of their pieces
detect.py          plan PDF -> plan JSON
vector.py          PDF lines, curves, fills and words (poppler)
furnish.py         furniture rules (pure Python)
quantities.py      areas, paint, tiles, doors, windows and furniture counts (pure Python)
themes.py          interior themes: the model library, the built-in themes, checks for your own
catalog.py         the built-in pieces' sizes and the preview row the Themes page photographs
fetch_assets.py    downloads the CC0 textures, models and sky
blender/           gen.py (build), furniture.py (pieces), bake.py (light maps), lib.py (materials, meshes), cinema.py (video renderer)
web/               home, review and walkthrough pages
examples/          sample_plan.pdf, its generator, embed.html
tests/             detector, furniture, walking and browser tests
tools/             video and debugging helpers
AGENTS.md          guide for AI coding agents working on this project
jobs/              one folder per uploaded plan (not in git)
assets/            downloaded materials (not in git)

Tests

tests/run_all.sh                                   # detector on the sample, quantities, server guards, furniture clashes, stair and wall walking
CHROME=/path/to/chromium node tests/test_site.mjs examples/sample_plan.pdf http://127.0.0.1:8080

GitHub Actions runs tests/run_all.sh on every push to main and every pull request (.github/workflows/tests.yml); it has no Blender, so run test_site.mjs yourself after changes to web/, server.py, jobs.py, theme_store.py or blender/.

test_site.mjs drives a real headless browser against a running server (about 2 min, one draft build): upload page, Furniture box, build box, screenshot, recording, map and top view. tests/test_detect.py scores the detector on the private drawings and is skipped unless PLANTO3D_FIXTURES points at them.

Extras

  • blender/cinema.py renders a dusk video tour of a built house along a camera path, pausing when the GPU or CPU gets hot. python3 fetch_assets.py --tour fetches its sky.
  • tools/tour.py, tools/record.mjs, tools/titles.py, tools/retime.py, tools/fill_frames.py: plan a walking route, record it from the viewer, add room titles, change speed, fill skipped frames.
  • tools/dbg_plan.py draws a plan JSON over its PDF page.

Limits

  • Vector PDFs only. Scans, photos and images are refused.
  • VR was tested with a simulated headset in Chromium, not on real hardware yet.
  • Axis-aligned walls. Slanted and curved walls are not detected; draw them on the review page.
  • Labels in English, sizes in feet and inches. Without size labels the scale is a guess and must be set on the review page.
  • Wall groups. If the drawing's walls fall into groups whose outlines do not overlap, the detector reads them as separate plans and can drop a part of the house.
  • No login. Anyone who can reach the server can upload, build and read every plan. Keep it on a trusted network or behind your own backend. --cors * lets any website call it from the visitor's browser: name your origin instead.
  • Disk. Plans stay until you delete them; a built house takes about 10 to 70 MB in jobs/.

Credits