# Why Raster Image AI Fails at Floor Plans (and How to Compile Prompts and Sketches into Real Vector CAD in TypeScript)

> Source: <https://dev.to/clara_sutton/why-raster-image-ai-fails-at-floor-plans-and-how-to-compile-prompts-and-sketches-into-real-vector-o6d>
> Published: 2026-11-26 16:41:05+00:00

**Recommendation:** Run a synchronous geometry healer on generated or scanned plans—weld near-duplicate vertices, snap walls within ±6° of 0°/90°, and re-weld at 4"—before rendering, or room areas collapse to zero.
More in the playbook "Verifying model output": <https://wpnews.pro/playbooks/output-verification>

Ask any general-purpose image diffusion model for a *"3-bedroom, 1,500 sq ft ranch floor plan with a 12×10 kitchen island"* and you will get something that looks architectural from six feet away—and falls apart the second you zoom in.

The dimension strings are melted gibberish. A bedroom labeled `"14' x 12'"` sits next to a bathroom that is visually wider than the bedroom. Doors open directly into kitchen islands. And worst of all, the output is a flat raster PNG. If a homeowner wants to move one partition wall 18 inches to widen a pantry, or hand the drawing to a draftsman in AutoCAD, the image is useless. You have to redraw the entire house from scratch.

When we built **[PlanCaliber](https://www.plancaliber.com/ai-floor-plan-generator?utm_source=devto&utm_medium=article&utm_campaign=devto_vector_ai_cad)**—a browser-based 2D/3D CAD drafting studio—we made a strict architectural rule from day one: **never generate pixels where the user needs geometry.**

Here is how our compilation pipeline turns either a plain-English building program or a hand-drawn phone photo / PDF into an editable, closed-polygon CAD wall graph in TypeScript, ready for true `1/4"=1'-0"` vector PDFs and 8-layer AutoCAD R12 `.DXF` export.

A real architectural floor plan is a **planar straight-line graph (PSLG)** with semantic constraints attached to edges, vertices, and faces:

`degree >= 2`) so rooms form watertight polygons whose areas can be computed deterministically via the shoelace formula—and classified into ANSI Z765 heated Gross Living Area (GLA) vs. unheated garage, shop, or porch bays.`6"` exterior framing, `4.5"` interior partitions), double-line mitered corners, and collinearity relationships across T-junctions.`(wallId, offsetIn, widthIn, swingDir)` rather than disconnected ink lines—so moving a wall moves every door and window mounted on it.`42"` for a single cook (`48"` for two cooks), and an IRC R310 bedroom egress window needs `5.7 sq ft` of net clear opening (`20"` min width, `24"` min height).
Diffusion models operate in latent pixel space. They have no concept of an invariant graph, no unit coordinate system (`$INSUNITS=1` US inches), and no way to guarantee that `Room A + Room B + Wall Thickness = Exterior Footprint`.

Instead of asking a model to paint an image, our **[AI Floor Plan Generator](https://www.plancaliber.com/ai-floor-plan-generator?utm_source=devto&utm_medium=article&utm_campaign=devto_vector_ai_cad)** treats both **Text-to-CAD** and **Sketch/PDF-to-CAD** as front-end parsing stages into a strict intermediate representation (`PlanDocument`):

```
export interface PlanDocument {
  walls: WallSegment[];      // endpoints in inches, thicknessIn, isExterior
  openings: WallOpening[];   // host wallId, offsetIn, widthIn, kind, swing
  fixtures: PlanFixture[];   // cabinets, islands, plumbing, electrical
  roomHints: RoomHint[];     // semantic labels + heated/unheated flags
}
```

Every coordinate in `PlanDocument` lives in **real-world US inches**, quantized on a `0.25"` (`1/4"`) drafting grid via `snapInches(value, 0.25)`.

Even with strict JSON schemas, raw coordinates extracted from a napkin sketch or synthesized from a natural-language prompt always contain small topological flaws:

`2.5"` apart (`degree 1` dangling edges that prevent room polygon closure).`2°` to `5°` off true horizontal or vertical.
If you hand that raw graph straight to a CAD renderer or `.DXF` exporter, room areas collapse to `0 sq ft` and dimension chains break.

`healPlanDocument`)
Before a generated or scanned floor plan ever reaches the interactive canvas, it runs synchronously through our TypeScript geometry healer (`healPlanDocument`):

`weldVerticesInPlace`)` 0.25"`-quantized centroid, and closes micro-gaps that would otherwise break face traversal.`snapWallAnglesInPlace`)`±6°` of `0°` or `90°` rotates cleanly onto the orthogonal axis around its midpoint, followed by a tight `4"` re-weld pass. Intentional 45° bay windows or angled walls outside `splitCrossingsAndTJunctionsInPlace`)` clampOpeningsInPlace`)` 3"` clear of corner miters so jambs never collide with perpendicular drywall.
Once healed, our planar half-edge face solver extracts every minimal enclosed cycle, removes the unbounded outer perimeter face, matches room hint points inside polygons, and computes exact wall-to-wall square footage and ANSI Z765 heated GLA in milliseconds—entirely client-side in the browser.

`rescalePlanToWall`)
When someone snaps a phone photo of a hand sketch or uploads a multi-page PDF into **[PlanCaliber's Sketch & PDF-to-CAD studio](https://www.plancaliber.com/sketch-to-cad?utm_source=devto&utm_medium=article&utm_campaign=devto_vector_ai_cad)**, pixel dimensions don't automatically equal feet and inches.

Our two-point calibration engine (`rescalePlanToWall`) lets the user click any single known wall—or even a standard `36"` entry door—and type its real measurement (for example `24'-6"`). From that single reference ratio:

`2"` framing increments (`18"` to `120"`), while cabinetry and fixtures snap to And when a user later edits a wall length directly (`setWallLength`), the engine walks collinear split wall chains across healed T-junctions so stretching a bedroom wall shifts the entire aligned facade cleanly without ripping the perimeter apart.

Because the source of truth is a true-scale planar CAD graph instead of a flat image, every downstream export compiles deterministically from the exact same math:

`1/4"=1'-0"` or `1/8"=1'-0"` scale (`A-101` Dimensioned Floor Plan, `A-102` Furniture & Fixture Plan, `E-101` Electrical & Lighting Plan, `A-201` Exterior Elevations, and `M-101` Clean White MLS Presentation Plan).`AC1009`) ASCII `.DXF`` 1:1` Model Space scale (`$INSUNITS=1` inches, North-up `+Y`) across 8 standard AIA layers (` A-WALL`, `A-DOOR`, `A-GLAZ`, `A-CABN`, `A-FURN`, `E-POWR`, `A-ROOM`, and `A-DIMS`), opening directly in AutoCAD, Revit, SketchUp Pro, Rhino, LibreCAD, and QCAD.`.OBJ/.MTL` & Framing Takeoff `.CSV`
You can inspect unlocked real compiler output directly before opening the studio:

AI shines in drafting when it eliminates the tedious blank-page step—converting a messy paper sketch, a real-estate PDF, or a plain-English room list into a clean starting geometry—while deterministic CAD engineering takes over for scale, clearances, editing, and plotting.

You can open **[PlanCaliber's AI Floor Plan Generator](https://www.plancaliber.com/ai-floor-plan-generator?utm_source=devto&utm_medium=article&utm_campaign=devto_vector_ai_cad)** right in your browser with no account required, run up to 2 free AI scans or text-to-CAD generations per day, edit every wall to `1/4"` precision in 2D and 3D, and only pay a simple one-time pass (`$9` for clean scaled PDF/PNG/SVG + share link, or `$19` for the full 5-sheet CAD + AutoCAD `.DXF` pack, no subscription, 14-day instant refund) when you are ready for clean exports.

*Note: PlanCaliber produces preliminary space-planning and architectural drafting documents—not licensed architectural or structural engineering stamps. Always verify dimensions and local building codes on site before construction or permit submission.*
