Skip to content

Repository files navigation

FloorPlan4

A native ArchiCAD 29 add-on that generates apartment floor plan variants (M1–M5 categories) inside any drawn boundary, under the constraints of the Polish Building Code (WT 2002).

The solver is built on Google OR-Tools CP-SAT. The UI is a modeless ArchiCAD palette (DG framework). The add-on draws real walls, doors, and zones into the model — not just a preview.

Status: experimental research project. Working on macOS, Windows build wired up via GitHub Actions. Open to ideas and contributions — see Contributing below.


Why this exists

Apartment plans in Poland are heavily regulated. Architects iterate manually on layouts that must respect minimum room dimensions, daylight access, adjacency rules, and a long list of building-code constraints. This add-on treats apartment layout as a constraint satisfaction problem and asks a CP-SAT solver to enumerate diverse, code-compliant variants for a given boundary — then writes the chosen one straight into the ArchiCAD model.

Why a native C++ add-on (instead of a Python tool over Tapir)?

  1. Single-file install (.bundle on macOS, .apx on Windows) — drag & drop
  2. Direct ACAPI wall + door creation (Tapir can't create door openings)
  3. Modeless palette integrated with ArchiCAD UI

Workflow

Menu "FloorPlan4" → toggle palette
┌─────────────────────────────┐
│  [preview canvas]           │  ← draws boundary + rooms + doors
│                             │
│  6.0 × 8.0m  48.0m²  M2     │  ← info text
│  Variant 2/5  Score: 0.83   │
│                             │
│  [Read][Generate][◀][▶][Insert]│
└─────────────────────────────┘
  1. Select walls (or click a point inside a closed space) — the add-on reads the boundary polygon and detects facade vs. internal edges.
  2. Hit Generate — the engine enumerates templates × facade configurations × arrangements, runs CP-SAT for each, validates against WT 2002, scores 0.0–1.0, and keeps the top variants.
  3. Browse ◀ ▶, hit Insert — partition walls, door openings, and labelled zones are created in the model.

What works

  • ✅ Modeless ArchiCAD palette (toggle from menu, resize, persistent)
  • ✅ Boundary reading from wall selection or point-click (auto temp-zone)
  • ✅ Polygon cleanup: duplicates, near-coincident vertices, collinear points
  • ✅ Auto-detect M1–M5 apartment type by area
  • ✅ CP-SAT solver with WT 2002 constraints (10 hard rules R1–R10)
    • Exact coverage equality, NoOverlap2D, hub topology, facade adjacency, min shared edge 90 cm, aspect ratio caps
  • ✅ Six base templates (M1, M2, M3, M4, M4 with two bathrooms, M5)
  • ✅ Variant diversity via facade rotation + quadrant blocking + flip
  • ✅ L-shape and trapezoid handling (Sutherland-Hodgman clipping; L/U obstacle split)
  • ✅ Validator (WT 2002 minimum areas, widths, daylight requirements)
  • ✅ Scorer (proportions, hub compactness, area deviation)
  • ✅ Wall + door + zone creation in ArchiCAD
  • Stage 1 — MPZP plot analyzer: plot polygon reader, zoning validation, plot subdivision into building lots, internal road network (35/35 tests passing)

In progress

  • 🚧 Polygon fill for irregular boundaries (some shapes leave uncovered area)
  • 🚧 Edge cases on small L-shapes for M3 (5 rooms + exact coverage may be geometrically infeasible — solver correctly rejects, but UX could be clearer about why)
  • 🚧 Floor-level partitioning (multi-apartment) — engine in place, no UI variant browsing yet
  • 🚧 Verified Windows .apx build (CI is wired, end-to-end install untested)

Roadmap

This project follows a four-stage architecture, of which Stage 4 (apartment generation) is the most mature today:

  • Stage 1 — MPZP plot analyzer (✅ engine done, 🚧 visualizer)
  • Stage 2 — Building footprint placement on plot (📋 planned)
  • Stage 3 — Floor partitioning into apartment cells (🚧 partial)
  • Stage 4 — Apartment plan generation (✅ working)

Build

macOS

brew install or-tools cmake
git clone https://github.com/poolpet/floorplan4.git
cd floorplan4
./deploy.sh                        # builds + installs into ArchiCAD

deploy.sh assumes ArchiCAD 29 in /Applications/Graphisoft/Archicad 29/. For localized AC (e.g. Polish "Dodatki"), override ADDON_DIR:

ADDON_DIR="/Applications/Graphisoft/Archicad 29/Dodatki" ./deploy.sh

You also need the ArchiCAD API DevKit 29 in a sibling directory ../API archicad/, or pass the path with -DAC_API_DEVKIT_DIR=....

Windows

See BUILD_WINDOWS.md. A GitHub Actions workflow (.github/workflows/build-windows.yml) builds the .apx automatically on every push.

Architecture

See ARCHITECTURE.md for the full breakdown — module graph, data flow, CP-SAT model, and the inviolable layout rules.

Short version:

  • FloorPlan4Engine — static library, no ArchiCAD dependency, testable standalone via FloorApartmentTest / FloorPartitionTest / MPZPTest
  • AddOn.bundle / .apx plugin that links the engine and adds the ArchiCAD-side bits (palette, boundary reader, plan writer)
  • Data/templates/*.json — 6 base templates (M1–M5)

A note on language

Room IDs (hub, lazienka, salon, kuchnia, sypialnia, wc, przedpokoj) and template type names are kept in Polish because the target user is a Polish architect designing under Polish building code, and these IDs map directly to legal definitions. The code, comments, documentation, and error messages are in English. UI labels in the ArchiCAD palette are currently mixed Polish/English while the project stabilizes.

Contributing

I'm building this in the open and I'm very open to ideas, suggestions, and pull requests — whether that's fresh apartment templates, better solver heuristics, support for other building codes, Windows verification, visualizer improvements, or just thinking about the bigger picture (building → floor → apartment pipeline).

If you want to talk before opening a PR, file an issue and tell me what you're thinking. There's no rigid contribution checklist — common sense and not breaking the existing tests is enough.

License

GNU General Public License v3.0

About

Native ArchiCAD 29 add-on — apartment plan generator (M1-M5) using OR-Tools CP-SAT, under Polish Building Code (WT 2002) constraints. Open to ideas.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages