CAD drawing JSON format
ERPSqlite stores every CAD drawing as a JSON document. It is the same format that is exported and imported:
- in the app: CAD → the drawing's menu → Download JSON, or inside the drawing File → Save as JSON…; to import it, Open DXF/DWG/JSON or drag it onto the Drawings list;
- with the app's AI: CAD → JSON Generator, a chat that draws or edits in this format from a text and an image or PDF, and shows the result before saving it;
- through the API:
GET /api/cad/drawings/{id}/jsonexports it andPOST /api/cad/drawingswith{"file": ...}imports it (see the CAD API for AI).
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": { ... }
}| Key | Required | Meaning |
|---|---|---|
format | yes | Always "erpsqlite-cad" |
version | yes | Format version: 1 |
name | no | Drawing name when imported |
units | no | Informative; the units that count are drawing.units |
exported | no | Export date and time |
drawing | yes | The drawing (below) |
The drawing object alone, without the wrapper, can be imported too.
2. Units, axes and angles
- Coordinates are in the drawing units (
drawing.units):mm(default),cmorm. - Y grows upwards.
- Angles in the file are in radians, counter-clockwise from +X: arcs (
a0,a1) and text and block rotation (rot). The operations API uses degrees; the file, radians. - Colours are AutoCAD ACI colour numbers: 1 red, 2 yellow, 3 green, 4 cyan, 5 blue, 6 magenta, 7 white/black, 8 grey, 9 light grey, 30 orange.
- Lineweights (
lw) are in millimetres: 0.13, 0.18, 0.25, 0.35, 0.5, 0.7…
3. The drawing (drawing)
| Key | Type | Meaning |
|---|---|---|
layers | list | Layers (section 4). Layer "0" always exists |
entities | list | Entities, in drawing order (section 5) |
current | text | Current layer (where new things are drawn) |
units | text | mm, cm or m |
dim | object | Dimension style (section 7) |
grid | number | Grid spacing |
snap | number | Snap step |
ltscale | number | Linetype scale |
textsize | number | Default text height |
modes | object | Active aids: snap, grid, ortho, polar, osnap, lwt (true/false) |
view | list | Saved view [x, y, scale] (optional) |
plan | object | The floor plan (floorplan) the walls came from, if any |
budget | number | Id of the linked budget (optional) |
arch | object | Architecture settings: thicknesses, heights, door and window styles (optional) |
st, earth, gis, site, bm | object | Structures, 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}| Key | Meaning |
|---|---|
name | Name (unique) |
color | Layer ACI colour (default 7) |
ltype | CONTINUOUS, DASHED, HIDDEN, CENTER, DASHDOT, DOT… (default CONTINUOUS) |
lw | Lineweight in mm (default 0.25) |
on | false = layer off (hidden) |
locked | true = locked (cannot be changed) |
bc | Ids of budget items linked to the whole layer |
5. Entities (entities)
Every entity shares these keys:
| Key | Meaning |
|---|---|
t | Type: line, pline, circle, arc, point, text, dim, wall, block or hatch |
p | Points [[x, y], ...] |
l | Layer (without l, layer "0") |
c | Own ACI colour (without c, the layer's) |
lt | Own linetype (without it, the layer's) |
lw | Own lineweight in mm (without it, the layer's) |
g | Tag: the element's name ("living room window") |
hz | 3D height (extrusion) |
z | 3D base elevation |
mt | Material (for 3D and quantities): brick, block (concrete block), concrete, stone, tile, wood, grass or glass |
bc | Ids of budget items linked to the entity |
xd | Own data of walls and blocks |
By type:
t | Points p | Other keys |
|---|---|---|
line | 2: start and end | |
pline | Its vertices | cl: true closed (rectangles, outlines) |
circle | 1: the centre | r radius |
arc | 1: the centre | r radius, a0 start and a1 end angle, in radians and counter-clockwise |
point | 1 | |
text | 1: insertion point | x text, h height, rot rotation in radians |
dim | Depends on the kind (below) | k dimension kind, x text replacing the measurement, rot |
wall | The wall axis | cl closed; hz height; in xd: th thickness and ops openings (section 6) |
block | 1: insertion point | rot rotation in radians; in xd: b block key, k scale, mx mirrored |
hatch | The ends of its strokes, two by two | Hatching: each pair of points is a separate line |
Dimensions (`dim`), by k:
k | Points 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 |
lead | The 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 key | Meaning |
|---|---|
k | door or window |
op | How it opens. Doors: simple, double, sliding or garage. Windows: single, double, sliding, fixed or tilt |
at | Position of the opening centre, measured along the axis from its first point (in drawing units) |
w, h | Width and height |
sill | Sill 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) |
st | Library 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}| Key | Meaning |
|---|---|
txt | Text height (on paper) |
asz | Arrow or tick size |
exo | Gap between the extension lines and the object |
exe | How far the extension lines go past the dimension line |
dec | Decimals |
tick | true: oblique ticks (architecture) instead of arrows |
suf | Text suffix (" mm") |
scale | Scale: 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
- To modify a drawing, change only what is needed and keep the rest of the JSON as it is, including keys you do not understand (
arch,st,plan…). - Declare layers in
layersbefore using them inl; a missing layer is created when used, but without its own colour or lineweight. - Use clear
gtags: they select the elements later, also through the API. - Rectangles and outlines:
plinewithcl: true. Walls with real thickness:wall, always withhz: without a height it stays flat in 3D. - An entity is a plan outline with a height
hzand a base elevationz. A Z per point is ignored, so there are no sloped roofs or meshes. - A building with several storeys is requested with the
floorplanoperation and itslevelslist (section 10), not object by object. - Remember that angles in the file are in radians (90° = 1.570796).
- To draw or change something in a drawing that is already in the ERP, the CAD API is easier than rewriting the whole file: its operations work in degrees and return the updated drawing.
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 }]
}
]
}| Key | What it is |
|---|---|
name | Name of the storey. It must be unique; without it, “Nivel 1”, “Nivel 2”… |
height | Height of its walls (without it, the one at the top of the operation, or else 2500). |
slab | Thickness of the floor slab above it (200 by default). The one on the last level is not used. |
rooms, doors, windows | As in a single-storey plan. Each level has its own footprint, and a name only has to be unique inside its level. |
- Each level starts at the sum of the heights and slabs of the levels below it.
- The program puts the slab on each level, with the footprint of that level and of the one above, and the roof on the last one. It also adds the roof without
roof; with"roof": falseit stays open. typeacceptsroom,porch(covered, with posts),terrace(in the open, with a 1 m railing on upper levels; use it for balconies and setbacks) andstair.- A stair is a
stairroom repeated on the level above with the samex,y,wandh: the program opens the slab and draws the steps, in one flight if they fit and in a U with a landing if not. - Each level has its own layers (“Nivel 2 Muros”, “Nivel 2 Forjado”, “Nivel 2 Escalera”…). The plan shows one level at a time and the 3D view the whole building; a level hidden in plan has
"po": trueon its layer, which is not the same as"on": false. - IFC export creates one storey per level, and the budget quantities come per level.
- Rooms are still rectangular and roofs flat, with no slopes. What the AI gets from a photo is an estimate.