{"slug": "why-raster-image-ai-fails-at-floor-plans-and-how-to-compile-prompts-and-sketches", "title": "Why Raster Image AI Fails at Floor Plans (and How to Compile Prompts and Sketches into Real Vector CAD in TypeScript)", "summary": "The team behind PlanCaliber, a browser-based 2D/3D CAD drafting studio, built a TypeScript pipeline that compiles plain-English building programs and hand-drawn sketches or PDFs into editable vector floor plans rather than raster images. The system parses inputs into a PlanDocument intermediate representation with coordinates in real-world US inches quantized to a 0.25-inch drafting grid, then runs a synchronous geometry healer that welds near-duplicate vertices, snaps walls within ±6° of orthogonal axes, and closes micro-gaps so rooms form watertight polygons. The output supports vector PDFs at 1/4\"=1'-0\" and 8-layer AutoCAD R12 .DXF export.", "body_md": "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.\n\nThe 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.\n\nWhen 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.**\n\nHere 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.\n\nA real architectural floor plan is a **planar straight-line graph (PSLG)** with semantic constraints attached to edges, vertices, and faces:\n\n`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).\nDiffusion 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`.\n\nInstead 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`):\n\n```\nexport interface PlanDocument {\n  walls: WallSegment[];      // endpoints in inches, thicknessIn, isExterior\n  openings: WallOpening[];   // host wallId, offsetIn, widthIn, kind, swing\n  fixtures: PlanFixture[];   // cabinets, islands, plumbing, electrical\n  roomHints: RoomHint[];     // semantic labels + heated/unheated flags\n}\n```\n\nEvery coordinate in `PlanDocument` lives in **real-world US inches**, quantized on a `0.25\"` (`1/4\"`) drafting grid via `snapInches(value, 0.25)`.\n\nEven with strict JSON schemas, raw coordinates extracted from a napkin sketch or synthesized from a natural-language prompt always contain small topological flaws:\n\n`2.5\"` apart (`degree 1` dangling edges that prevent room polygon closure).`2°` to `5°` off true horizontal or vertical.\nIf you hand that raw graph straight to a CAD renderer or `.DXF` exporter, room areas collapse to `0 sq ft` and dimension chains break.\n\n`healPlanDocument`)\nBefore a generated or scanned floor plan ever reaches the interactive canvas, it runs synchronously through our TypeScript geometry healer (`healPlanDocument`):\n\n`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.\nOnce 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.\n\n`rescalePlanToWall`)\nWhen 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.\n\nOur 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:\n\n`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.\n\nBecause 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:\n\n`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`\nYou can inspect unlocked real compiler output directly before opening the studio:\n\nAI 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.\n\nYou 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.\n\n*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.*", "url": "https://wpnews.pro/news/why-raster-image-ai-fails-at-floor-plans-and-how-to-compile-prompts-and-sketches", "canonical_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_at": "2026-11-26 16:41:05+00:00", "updated_at": "2026-11-26 16:45:13.546510+00:00", "lang": "en", "topics": ["ai-tools", "generative-ai", "developer-tools", "ai-products"], "entities": ["PlanCaliber", "AutoCAD", "TypeScript"], "also_reported_by": [], "takeaway": "Treat text and sketch inputs as parsing stages into a strict PlanDocument of walls, openings, fixtures and room hints in quantized inches, then heal the graph by welding vertices within 0.25\" and snapping walls within ±6° of orthogonal before rendering or DXF export.", "recommendation": {"advice": "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.", "playbook": "output-verification", "playbook_url": "https://wpnews.pro/playbooks/output-verification"}, "alternates": {"html": "https://wpnews.pro/news/why-raster-image-ai-fails-at-floor-plans-and-how-to-compile-prompts-and-sketches", "markdown": "https://wpnews.pro/news/why-raster-image-ai-fails-at-floor-plans-and-how-to-compile-prompts-and-sketches.md", "text": "https://wpnews.pro/news/why-raster-image-ai-fails-at-floor-plans-and-how-to-compile-prompts-and-sketches.txt", "jsonld": "https://wpnews.pro/news/why-raster-image-ai-fails-at-floor-plans-and-how-to-compile-prompts-and-sketches.jsonld"}}