Hand-drawn remodel sketches, phone photos of old blueprints, and scanned real estate brochures all share the same problem: pixels have no physical scale. Even when a vision model accurately detects every wall, doorway, window, and room label, the output is useless for real layout work or contractor estimating until those normalized coordinates map onto exact US feet and inches.
When we engineered PlanCaliber's AI Sketch & PDF-to-CAD Importer, we combined vision extraction with a deterministic 1-wall calibration, orthogonal angle snapping, and T-junction wall-graph cleanup pass written in pure TypeScript.
1. Why One Known Wall Calibrates an Entire Plan
Asking a user to measure twelve separate rooms defeats the entire purpose of tracing a sketch. Instead, a single known wall segment with pixel endpoints (x1, y1) and (x2, y2) and real-world length knownLengthFt sets a uniform scale factor for the entire orthographic drawing:
export interface Point2D { x: number; y: number; } export interface CalibratedWall { id: string; x1: number; y1: number; x2: number; y2: number; thicknessFt: number; } export function calibratePixelsToFeet( refStartPx: Point2D, refEndPx: Point2D, knownLengthFt: number ): number { const pixelDist = Math.hypot(refEndPx.x - refStartPx.x, refEndPx.y - refStartPx.y); if (pixelDist <= 0 || knownLengthFt <= 0) { throw new Error('Reference wall pixel distance and known length must be positive'); } return pixelDist / knownLengthFt; // pixels per foot } A subtle practical detail matters enormously in the field: calibrating off the longest known wall (15' to 30') cuts relative quantization error by 3x to 5x compared to calibrating off a 3'-0" doorway. If a click lands 2 px off on a 60 px doorway (3'), every room across a 40' house drifts by 16". The exact same 2 px click error on a 600 px (30') exterior wall causes less than 1.2" of drift across the entire footprint.
2. Snapping to a 1-Inch Imperial Grid and Merging Near-Collinear Walls
Raw raster traces produce slightly skewed walls (89.2 degrees instead of 90 degrees) and hairline 0.04' gaps at corners that break polygon area calculation (ANSI Z765 GLA) and leave cracks in 3D extrusions. Before handing geometry to our CAD canvas, we run three deterministic passes:
const GRID_STEP_FT = 1 / 12; // 1-inch US imperial snap grid export function snapToInch(feet: number): number { return Math.round(feet / GRID_STEP_FT) * GRID_STEP_FT; } export function orthogonalizeWall(wall: CalibratedWall, angleToleranceDeg = 4): CalibratedWall { const dx = wall.x2 - wall.x1; const dy = wall.y2 - wall.y1; const angleDeg = (Math.atan2(Math.abs(dy), Math.abs(dx)) * 180) / Math.PI; let x1 = snapToInch(wall.x1); let y1 = snapToInch(wall.y1); let x2 = snapToInch(wall.x2); let y2 = snapToInch(wall.y2); if (angleDeg <= angleToleranceDeg) { const avgY = snapToInch((y1 + y2) / 2); y1 = avgY; y2 = avgY; } else if (Math.abs(90 - angleDeg) <= angleToleranceDeg) { const avgX = snapToInch((x1 + x2) / 2); x1 = avgX; x2 = avgX; } return { ...wall, x1, y1, x2, y2 }; } Following orthogonalization, an endpoint-clustering pass snaps any two wall endpoints within 0.35' (4.2") onto their shared corner vertex, and projects interior partition endpoints onto perimeter wall segments to form clean T-junctions.
3. From Calibrated Wall Graph to Scale-True PDF, DXF, and 3D
Once every wall lives on an exact imperial feet/inch coordinate system, every downstream deliverable becomes purely deterministic math:
- Live ANSI Z765 Room & Footprint Area: Shoelace polygon areas over closed wall cycles update on every wall drag.
- Scale-True
1/4" = 1'-0"Vector PDF (A-101throughM-101):1'in world space maps to18 pt(0.25 in * 72 pt/in) onARCH DorANSI Bsheets with zero raster blurring. - Layered AutoCAD R12
.DXF: Multiplies world feet by12.0($INSUNITS = 1inches) and writes cleanLINE,ARC, andTEXTentities across 8 AIA layers (A-WALL,A-DOOR,A-GLAZ,A-CABN,A-FURN,E-POWR,A-ROOM,A-DIMS). - 3D
.OBJ/.MTLWalkthrough: Extrudes each wall centerline bythicknessFtand ceiling height with boolean door/window cutouts.
Try Sketch-to-CAD Free in Your Browser
- Upload a hand sketch, phone photo, or existing PDF floor plan with
2free AI scans per day inside PlanCaliber Sketch-to-CAD or try text-to-floor-plan generation via our AI Floor Plan Generator. - Verify blueprint print scales before plotting using our free Floor Plan Scale Calculator, or explore MLS-ready layouts on Real Estate Floor Plans.
- Draft, edit in 2D/3D, and download a watermarked proof PNG free; unlock clean unwatermarked vector PDFs from
$9one-time or 5-sheet1/4"=1'-0"CAD + AutoCAD.DXF+ 3D.OBJ+ framing/drywall.CSVpacks for$19one-time (see full pricing & specs).
Preliminary space-planning and layout drafting tool. Verify all dimensions, structural elements, and local building codes on site before construction.