When we built EgressCAD for event planners, tent rental crews, and venue operators who need municipal Fire Marshal permit submittals, we wanted to avoid running headless Chrome, LibreCAD, or a heavy native CAD microservice just to export drawings.
Everything runs inside a single SvelteKit app deployed on Cloudflare Workers: a pure-TypeScript IFC/NFPA compliance solver, a true-scale 3-sheet 11"x17" architectural PDF generator using pdf-lib, and a zero-dependency AutoCAD R2000 (AC1015) DXF emitter.
Here is how the coordinate math, CAD layering, and fire-code edition differences work in practice.
1. Two Coordinate Systems: Browser SVG vs. CAD & PDF
Interactive floor-plan editors in the browser work naturally in top-left origin coordinates (X increases East, Y increases South/down from the north wall).
Both AutoCAD DXF and PDF (pdf-lib) use bottom-left origin coordinates where Y increases North/up. Getting the flip wrong mirrors exits, heater setbacks, and north arrows silently.
In our DXF exporter, we emit geometry at true 1:1 scale in inches, with origin (0, 0) locked to the southwest corner of the tent or room:
const toCadX = (xFt: number) => Number((xFt * 12).toFixed(2)); const toCadY = (yFt: number) => Number(((config.lengthFt - yFt) * 12).toFixed(2)); Inside the DXF HEADER section, setting $ACADVER to AC1015 (AutoCAD R2000), $INSUNITS to 1 (Inches), and $LUNITS to 4 (Architectural feet-and-inches) ensures any architect or municipal plans examiner opening the file in AutoCAD, BricsCAD, or QCAD sees real architectural dimensions immediately with zero rescaling:
push( 0, 'SECTION', 2, 'HEADER', 9, '$ACADVER', 1, 'AC1015', 9, '$INSUNITS', 70, 1, // Inches 9, '$LUNITS', 70, 4, // Architectural 0, 'ENDSEC' ); 2. Seven AIA-Style CAD Layers Without an External CAD Kernel
Fire Marshals and downstream structural engineers expect separated CAD layers so they can toggle furniture off while verifying egress paths or extinguisher coverage. In pure TypeScript, defining the TABLES -> LAYER section takes fewer than 20 lines:
const LAYERS = [ { name: 'A-WALL-TENT', color: 7 }, // White/Black perimeter walls { name: 'A-FURN-SEAT', color: 8 }, // Gray tables, chairs, stages { name: 'E-EXIT-SIGN', color: 3 }, // Green exit openings & signs { name: 'E-EGRESS-PATH', color: 3 }, // Green egress aisles & chords { name: 'F-EXTINGUISHER', color: 1 }, // Red 2A:10BC units & 75' radii { name: 'F-HAZARD-SETBACK', color: 1 }, // Red 10' heater/LP-gas zones { name: 'A-ANNO-DIMS', color: 5 } // Blue dimension annotations ]; Every LINE, CIRCLE, LWPOLYLINE, and TEXT entity simply references its layer name via group code 8. We also run every user-entered string through a strict ASCII sanitizer ([^\x20-\x7E] stripped, length capped) because raw newlines or smart quotes inside DXF group code 1 values corrupt older CAD parsers.
3. True-Scale 11"x17" Architectural PDFs in pdf-lib
Municipal permit desks almost universally ask for 11"x17" Tabloid Landscape (1224 x 792 pt at 72 pt/in) with a fixed right-hand architectural title block (216 pt wide), graphic scale bar, north arrow, and printed scale ratio (such as 1/16" = 1'-0" or 1/8" = 1'-0").
Rather than fitting the tent to arbitrary pixel percentages (which ruins architectural scaling when someone puts a physical scale ruler on printed paper), we snap the viewport scale to standard US architectural fractions:
-
1/4" = 1'-0"(18 ptper foot) -
1/8" = 1'-0"(9 ptper foot) -
1/16" = 1'-0"(4.5 ptper foot) -
1/32" = 1'-0"(2.25 ptper foot)
We pick the largest standard scale where the full tent + exterior setback margin fits inside the drawable frame, then draw a matching graphic scale bar (0' - 10' - 20' - 40') using the exact same ptPerFt multiplier. That way, even if an applicant prints "Fit to Page" on 8.5"x11" paper, the graphic scale bar remains proportionally valid.
One subtle gotcha with pdf-lib's built-in StandardFonts (Helvetica, Courier): they only encode WinAnsi characters. Any Unicode multiplication symbol (×), greater-than-or-equal sign (≥), or curly quote will throw a runtime encoding error unless normalized first:
function asciiSafe(input: string): string { return input .replace(/[\u2018\u2019]/g, "'") .replace(/[\u201C\u201D]/g, '"') .replace(/[\u2013\u2014]/g, '-') .replace(/\u00D7/g, 'x') .replace(/\u2265/g, '>=') .replace(/\u2264/g, '<=') .replace(/[^\x20-\x7E]/g, ' '); } 4. Handling Fire-Code Edition Drift Deterministically
Building a fire-code checker is mostly an exercise in not hardcoding a single textbook citation. US municipalities enforce different code cycles simultaneously:
- IFC 2024 renumbered the temporary tent exit table to Table 3103.11 (whereas IFC 2021 and IFC 2018 cite Table 3103.12.2).
- NFPA 101 uses Table 7.3.1.2 for occupant load factors (
15sq ft/person tables & chairs,7sq ft chairs only,5sq ft standing), whereas IFC uses Table 1004.5. - The half-diagonal exit separation rule (IFC Section 1007.1.1) requires two exits to be separated by at least
0.5 * sqrt(W^2 + L^2)in non-sprinklered tents and halls, dropping to1/3the diagonal only when full NFPA 13 automatic sprinkler coverage is present. - Winter events trigger IFC 3107.12 (10-ft clearance from open/indirect tent heaters to fabric) and IFC 3107.16 (10-ft minimum outdoor clearance for portable LP-gas containers under 500 gallons).
Because the entire compliance solver (compliance-solver.ts) is pure TypeScript with zero browser DOM dependencies, the exact same function drives both the live interactive SVG studio in the browser and the server-side PDF/DXF generators on Cloudflare Workers, guaranteeing the numbers on Sheet FP-102 always match what the user verified on screen.
Finally, software cannot replace a licensed engineer where local law requires a seal: our jurisdiction metadata explicitly flags cities like NYC, Chicago, Miami-Dade, Orlando, Tampa, Boston, and Washington DC whenever an architect or PE stamp may be triggered above local size or occupant thresholds.
If you want to inspect the live geometry checks, interactive IFC calculators, or a sample 3-sheet 11x17 PDF packet, you can try the studio directly with no signup at https://www.egresscad.com/.

