View as Markdown

CAD drawing JSON format

ERPSqlite stores every CAD drawing as a JSON document. It is the same format that is exported and imported:

With this specification an AI can read an exported drawing, generate one from scratch or modify it and hand it back for import.

This document as Markdown: https://www.erp-sqlite.xyz/docs/cad-json.en.md

1. The file

{
  "format": "erpsqlite-cad",
  "version": 1,
  "name": "Shed",
  "units": "mm",
  "exported": "2026-10-22T18:00:00",
  "drawing": { ... }
}
KeyRequiredMeaning
formatyesAlways "erpsqlite-cad"
versionyesFormat version: 1
namenoDrawing name when imported
unitsnoInformative; the units that count are drawing.units
exportednoExport date and time
drawingyesThe drawing (below)

The drawing object alone, without the wrapper, can be imported too.

2. Units, axes and angles

3. The drawing (drawing)

KeyTypeMeaning
layerslistLayers (section 4). Layer "0" always exists
entitieslistEntities, in drawing order (section 5)
currenttextCurrent layer (where new things are drawn)
unitstextmm, cm or m
dimobjectDimension style (section 7)
gridnumberGrid spacing
snapnumberSnap step
ltscalenumberLinetype scale
textsizenumberDefault text height
modesobjectActive aids: snap, grid, ortho, polar, osnap, lwt (true/false)
viewlistSaved view [x, y, scale] (optional)
planobjectThe floor plan (floorplan) the walls came from, if any
budgetnumberId of the linked budget (optional)
archobjectArchitecture settings: thicknesses, heights, door and window styles (optional)
st, earth, gis, site, bmobjectStructures, earthworks, map, site and measurements (optional; kept as they are)

Optional keys you do not know can be left out: defaults are used on import.

4. Layers (layers)

{"name": "Walls", "color": 7, "ltype": "CONTINUOUS", "lw": 0.5}
KeyMeaning
nameName (unique)
colorLayer ACI colour (default 7)
ltypeCONTINUOUS, DASHED, HIDDEN, CENTER, DASHDOT, DOT… (default CONTINUOUS)
lwLineweight in mm (default 0.25)
onfalse = layer off (hidden)
lockedtrue = locked (cannot be changed)
bcIds of budget items linked to the whole layer

5. Entities (entities)

Every entity shares these keys:

KeyMeaning
tType: line, pline, circle, arc, point, text, dim, wall, block or hatch
pPoints [[x, y], ...]
lLayer (without l, layer "0")
cOwn ACI colour (without c, the layer's)
ltOwn linetype (without it, the layer's)
lwOwn lineweight in mm (without it, the layer's)
gTag: the element's name ("living room window")
hz3D height (extrusion)
z3D base elevation
mtMaterial (for 3D and quantities): brick, block (concrete block), concrete, stone, tile, wood, grass or glass
bcIds of budget items linked to the entity
xdOwn data of walls and blocks

By type:

tPoints pOther keys
line2: start and end
plineIts verticescl: true closed (rectangles, outlines)
circle1: the centrer radius
arc1: the centrer radius, a0 start and a1 end angle, in radians and counter-clockwise
point1
text1: insertion pointx text, h height, rot rotation in radians
dimDepends on the kind (below)k dimension kind, x text replacing the measurement, rot
wallThe wall axiscl closed; hz height; in xd: th thickness and ops openings (section 6)
block1: insertion pointrot rotation in radians; in xd: b block key, k scale, mx mirrored
hatchThe ends of its strokes, two by twoHatching: each pair of points is a separate line

Dimensions (`dim`), by k:

kPoints p
lin[p1, p2, location]; rot 0 horizontal or π/2 (1.570796) vertical
ali[p1, p2, location], aligned with p1-p2
rad / dia[centre, point of the line], with r
ang[vertex, point on the first arm, point on the second, arc location]
ordx / ordy[point, leader end]; measures the X (ordx) or Y (ordy) of the point from the 0,0 origin
leadThe leader points; x the text
cen[centre], with r (centre mark)

6. Walls, doors and windows

A wall is a wall entity whose p is its axis. The thickness goes in xd.th and the openings in xd.ops:

{"t": "wall", "p": [[0, 0], [4000, 0], [4000, 3000], [0, 3000]], "cl": true,
 "l": "A-MUROS", "hz": 2500,
 "xd": {"th": 200, "ops": [
   {"k": "door", "op": "simple", "at": 2000, "w": 825, "h": 2030},
   {"k": "window", "op": "double", "at": 5500, "w": 1200, "h": 1200, "sill": 900}
 ]}}
Opening keyMeaning
kdoor or window
opHow it opens. Doors: simple, double, sliding or garage. Windows: single, double, sliding, fixed or tilt
atPosition of the opening centre, measured along the axis from its first point (in drawing units)
w, hWidth and height
sillSill height above the floor (windows)
hg"e": the leaf hinges on the end side (by default, the start side)
sd-1: opens to the right of the axis (default 1, to the left)
stLibrary style

For whole plans it is simpler to use the API's floorplan operation: it draws walls, openings, labels and dimensions at once. That operation is not a file (it goes in {"ops": [...]}, with angles in degrees), and a file holding only plan, without entities, opens empty.

7. Dimension style (dim)

{"txt": 2.5, "asz": 2.5, "exo": 1.25, "exe": 1.25, "dec": 0, "tick": true, "suf": "", "scale": 100}
KeyMeaning
txtText height (on paper)
aszArrow or tick size
exoGap between the extension lines and the object
exeHow far the extension lines go past the dimension line
decDecimals
ticktrue: oblique ticks (architecture) instead of arrows
sufText suffix (" mm")
scaleScale: sizes are multiplied by it (100 for a plan in mm at 1:100)

8. Full example

A valid file that can be imported as is: a 4 × 3 m room with a door and a window, a circle, an arc, a text and a dimension.

{
  "format": "erpsqlite-cad",
  "version": 1,
  "name": "Example",
  "units": "mm",
  "drawing": {
    "units": "mm",
    "current": "0",
    "textsize": 250,
    "grid": 500,
    "snap": 50,
    "dim": {"txt": 2.5, "asz": 2.5, "exo": 1.25, "exe": 1.25, "dec": 0, "tick": true, "suf": "", "scale": 100},
    "layers": [
      {"name": "0", "color": 7, "ltype": "CONTINUOUS", "lw": 0.25},
      {"name": "A-MUROS", "color": 7, "ltype": "CONTINUOUS", "lw": 0.5},
      {"name": "Text", "color": 3, "ltype": "CONTINUOUS", "lw": 0.18},
      {"name": "Dimensions", "color": 3, "ltype": "CONTINUOUS", "lw": 0.18},
      {"name": "Furniture", "color": 8, "ltype": "CONTINUOUS", "lw": 0.18}
    ],
    "entities": [
      {"t": "wall", "p": [[0, 0], [4000, 0], [4000, 3000], [0, 3000]], "cl": true, "l": "A-MUROS", "hz": 2500, "g": "walls",
       "xd": {"th": 200, "ops": [
         {"k": "door", "op": "simple", "at": 2000, "w": 825, "h": 2030},
         {"k": "window", "op": "double", "at": 5500, "w": 1200, "h": 1200, "sill": 900}
       ]}},
      {"t": "circle", "p": [[2000, 1500]], "r": 600, "l": "Furniture", "g": "table", "hz": 750},
      {"t": "arc", "p": [[0, 0]], "r": 825, "a0": 0, "a1": 1.570796, "l": "Furniture"},
      {"t": "text", "p": [[1400, 2500]], "x": "Living room 12 m²", "h": 200, "l": "Text", "g": "label"},
      {"t": "dim", "k": "lin", "p": [[0, 0], [4000, 0], [2000, -800]], "l": "Dimensions"}
    ]
  }
}

9. Tips for an AI

10. Buildings with several storeys

The floorplan operation of the JSON generator and of the API draws a whole plan from its rooms. For a building, levels replaces rooms, doors and windows, with one level per storey, from the ground floor up. Without levels, the operation is the usual single-storey one.

{
  "op": "floorplan",
  "replace": true,
  "exterior_wall": 200,
  "interior_wall": 100,
  "roof": { "thickness": 200 },
  "levels": [
    {
      "name": "Ground floor",
      "height": 2800,
      "slab": 200,
      "rooms": [
        { "name": "Living room", "x": 0, "y": 0, "w": 6000, "h": 5000 },
        { "name": "Stairs", "x": 6000, "y": 0, "w": 2500, "h": 5000, "type": "stair" }
      ],
      "doors": [{ "room": "Living room", "wall": "east", "at": 0.5 }],
      "windows": [{ "room": "Living room", "wall": "north", "at": 0.5, "width": 2400 }]
    },
    {
      "name": "First floor",
      "height": 2600,
      "rooms": [
        { "name": "Bedroom", "x": 2000, "y": 0, "w": 4000, "h": 5000 },
        { "name": "Stairs", "x": 6000, "y": 0, "w": 2500, "h": 5000, "type": "stair" },
        { "name": "Terrace", "x": 0, "y": 0, "w": 2000, "h": 5000, "type": "terrace" }
      ],
      "doors": [{ "room": "Bedroom", "wall": "east", "at": 0.5 }],
      "windows": [{ "room": "Bedroom", "wall": "north", "at": 0.5, "width": 1800 }]
    }
  ]
}
KeyWhat it is
nameName of the storey. It must be unique; without it, “Nivel 1”, “Nivel 2”…
heightHeight of its walls (without it, the one at the top of the operation, or else 2500).
slabThickness of the floor slab above it (200 by default). The one on the last level is not used.
rooms, doors, windowsAs in a single-storey plan. Each level has its own footprint, and a name only has to be unique inside its level.