cloudcad-api
Skill9 starsChanged 3 months agoMITView on GitHub
You are an agent that creates and manages SkyCiv CloudCAD drawings via the SkyCiv API. This skill covers the full CAD JSON schema and the cloudcad.model and cloudcad.file API namespaces. Prerequisite: Always begin a session with S3D.session.start as the first function. See the skyciv-core skill for auth, options, and the request/response envelope. A CAD model is a JSON object with this top-level structure: This object is passed to cloudcad.model.create as cad_data. blockReferences is camelCase and top-level, not block_references nested inside…
In this repository16 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- analysis-resultsSkill
- baseplateSkill
- build-quick-design-calculatorSkill
- load-combinationsSkill
- load-gen-apiSkill
- qa-engineerSkill
- rendererSkill
- run-quick-designSkill
- s3d-apiSkill
- s3d-appsSkill
- schema-agentSkill
- section-selectorSkill
- skill-writerSkill
- skyciv-api-v3Skill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 118
All length values are in mm and should scale with your drawing.
- Very specific: line 229
All array fields must be present (use [] if empty).
- Very specific: line 324
Always include attributeStyleId so arrow and text sizes are correct.
- Very specific: line 365
Always include attributeStyleId — the style's angleArrowShape, angleDimensionTextSize, angleTextOffset, and angleTextOrientation fields …
- Distinctive: line 695
Place a block on a canvas.
- Very specific: line 1117
All coordinates are 2D: x (horizontal) and y (vertical) on the canvas.
- Very specific: line 1131
Opening a previously saved drawing for editing: Use cloudcad.file.open to load it into the session, modify via API, then cloudcad.file.save …
- Very specific: line 1167
If you're on the SkyCiv platform (i.e.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Draftsperson Agent Skill (CAD API)
You are an agent that creates and manages SkyCiv CloudCAD drawings via the SkyCiv API. This skill covers the full CAD JSON schema and the cloudcad.model and cloudcad.file API namespaces.
Prerequisite: Always begin a session with
S3D.session.startas the first function. See theskyciv-coreskill for auth, options, and the request/response envelope.
CAD Data Format Overview
A CAD model is a JSON object with this top-level structure:
{
"settings": { ... }, // global display/snap/unit settings
"s3d": { ... }, // optional: structural 3D export mapping
"attributeStyles": [ ... ], // dimension/text/leader/axis sizing styles
"blockReferences": [ ... ], // block DEFINITIONS (reusable groups, e.g. title blocks) - see "Blocks" below
"pdfExport": { ... }, // optional: printed page setup (paper size, page frame) - see "Pages" below
"canvases": [ ... ] // array of drawing sheets
}This object is passed to cloudcad.model.create as cad_data.
blockReferencesis camelCase and top-level, notblock_referencesnested inside a canvas — a real, verified correction to this schema (confirmed against the live API and a genuine platform-exported file, see "Blocks" below). If you've seenblock_referencesreferenced elsewhere as a per-canvas snake_case field, that's stale.
settings
Controls display, units, snapping, and colors. All fields optional — defaults applied for any omitted values.
| Key | Type | Description |
canvasLengthUnits | string | "mm", "cm", "m", "ft", "in" |
gridSize | string | Grid spacing value |
snapToGrid | bool | Snap to grid |
snapToPoint | bool | Snap to existing points |
snapToLineEnds | bool | Snap to line endpoints |
snapToLineMid | bool | Snap to line midpoints |
snapToAlign | bool | Alignment guide snapping |
snapToAxis | bool | Axis snapping |
showGrid | bool | Show background grid |
showAxis | bool | Show axis lines |
showVertices | bool | Show vertex markers |
showCreatedDimensions | bool | Show user-created dimensions |
showSelectionDimensions | bool | Show dimensions on selection |
canvasBackgroundColor | string | Hex background color |
lineColor | string | Default line color |
pointColor | string | Default point color |
dimensionsColor | string | Dimension label color |
selectionColor | string | Selected item color |
highlightColor | string | Hover/highlight color |
dimensionTextSize | string | Font size for dimension labels |
globalDimsScale | string | Global dimension display scale |
globalTextScale | string | Global text display scale |
arcSegments | string | Segment count for arc rendering |
circleSegments | string | Segment count for circle rendering |
attributeStyles
Always include this field. Defines named styles for all annotation sizing: dimensions, text, leader texts, and axes. Elements reference a style by attributeStyleId. Without a style, annotations render at tiny default sizes that may not suit your drawing scale.
Define at least one style (conventionally "id": "as-default") and reference it on every annotation element.
"attributeStyles": [
{
"id": "as-default",
"name": "Default Style",
"settings": {
"linearArrowShape": "arrow",
"linearArrowLength": 216,
"linearArrowWidth": 216,
"linearExtLineStartOffset": 0,
"linearExtLineEndOffset": 0,
"linearTextOffset": 0,
"linearTextHorizontalOffset": 0,
"linearTextHorizontalPosition": "center",
"dimensionTextSize": 378,
"angleArrowShape": "arrow",
"angleArrowLength": 216,
"angleArrowWidth": 216,
"angleDimensionTextSize": 378,
"angleTextOffset": 600,
"angleTextOrientation": "horizontal",
"radiusArrowShape": "arrow",
"radiusArrowLength": 216,
"radiusArrowWidth": 216,
"radiusDimensionTextSize": 378,
"radiusTextOffset": 0,
"leaderArrowShape": "arrow",
"leaderArrowLength": 216,
"leaderArrowWidth": 216,
"leaderTextSize": 378,
"leaderTextOffsetHorizontal": 0,
"leaderTextOffsetVertical": 0,
"axisExtension": 5000,
"axisCircleDiameter": 1080,
"axisTextSize": 324,
"axisDashLength": 216,
"axisDashGap": 108,
"textSizeInput": 14,
"textSizeOverride": false,
"fontFamily": "monospace",
"tableFontSize": 400
}
}
]All length values are in mm and should scale with your drawing. The values above are suitable for a building-scale drawing (rooms in the thousands of mm). For small drawings (e.g. cross-sections at ~100 mm), divide all length values by ~10.
linearArrowShape / angleArrowShape / radiusArrowShape / leaderArrowShape: "arrow", "dot", "architectural", "none".
axisDashLength / axisDashGap control the dash-dot line pattern axes render with (the
standard drafting convention for gridlines/centerlines — a long dash, a gap, then a short
dash) — axisDashLength is the length of each dash segment, axisDashGap is the gap
between segments, both in mm. This is a property of the axis line itself, distinct
from lineType on a Layer (see "Layers" below), which controls dash style for ordinary
lines/polylines.
A real platform-exported style also carries per-dimension-type label formatting fields, confirmed from a live export — all optional, omit to use platform defaults:
Key pattern (linear/angle/radius) | Type | Description |
{type}Prefix / {type}Suffix | string | Text before/after the dimension value, e.g. "R" prefix for radius labels |
{type}Precision | number | Decimal places shown |
{type}DecimalSep | string | Decimal separator, e.g. "." |
{type}RoundOff | number | Round the displayed value to the nearest multiple of this |
{type}ToleranceType | string | "none" or a tolerance display mode |
{type}ToleranceUpper / {type}ToleranceLower | number | Tolerance band shown alongside the value |
linearShowUnits / radiusShowUnits | string | "yes" / "no" — show the unit suffix on the label |
angleUnitFormat | string | "decimal" (seen in a real export); degrees-minutes-seconds format is presumably also supported but not confirmed |
angleAltUnits | string | "none" (seen in a real export) — alternate unit display, not otherwise confirmed |
Elements that accept "attributeStyleId": dimensions, angleDimensions, radiusDimensions, leaderTexts, multiLeaderTexts, texts, axes, tables.
Supporting more than one plot scale? Scale the style, never the geometry. If your drawing generator picks between plot scales (e.g. 1:50 for a small object, 1:100 for a larger one that wouldn't fit at 1:50 — see "Never scale model geometry" below for why geometry itself must always stay true mm), define
attributeStylesper plot scale by multiplying every length-valued setting (dimensionTextSize,linearArrowLength/linearArrowWidth,angleTextOffset,axisExtension,axisDashLength/axisDashGap,tableFontSize, etc. — anything measured in mm, not a string enum) byk = chosenScale / baselineScale. Apply that samekto any reused page furniture (title block border, table) too. This keeps arrows, dimension text, and the title block at one constant physical size on the printed sheet no matter which plot scale a given drawing ends up using — confirmed working in a generator that adaptively picks between two plot scales per install.
s3d (Structural 3D Mapping)
Optional. Use when the CAD drawing maps to a structural model.
{
"s3d": {
"settings": {
"units": "mm",
"tolerance": 0.0001,
"connect_floors_by_columns": false,
"connect_floors_section_id": null,
"remove_duplicate_members": true,
"supports_only_base": true,
"ignore_unassigned_sections": false
},
"sections": {},
"elevations": [
{ "canvas_id": 0, "elevation": 0 }
]
}
}canvases
An array of canvas (drawing sheet) objects. Each canvas is a self-contained drawing.
{
"version": "2.0.0",
"schema": "canvas-json-v2-optimized",
"name": "Canvas 1",
"drawing_type": "Plan",
"is_base": true,
"points": [],
"lines": [],
"polylines": [],
"dimensions": [],
"angleDimensions": [],
"radiusDimensions": [],
"leaderTexts": [],
"multiLeaderTexts": [],
"texts": [],
"tables": [],
"axes": [],
"constructionLines": [],
"revisionClouds": [],
"hatches": [],
"images": [],
"block_instances": [],
"layers": [],
"s3d": {}
}Note: attributeStyles and blockReferences are top-level fields on the root object
(alongside settings and canvases), not inside each canvas — a canvas only places
blocks via block_instances, it doesn't define them. A per-canvas "block_references"
(snake_case) array can also appear — in a genuine platform-exported file this was not
empty, but a denormalized copy of the top-level blockReferences entries (same ids,
plus extra UI-only fields like sourceLibraryUid/sourceBlockId and per-item
layerIds). It's still not authoritative and safe to omit or leave as [] when creating
a drawing programmatically — always write block definitions to the top-level
blockReferences only.
drawing_type: "Plan", "Elevation", etc.
All array fields must be present (use [] if empty).
A real export also carries extra top-level/per-canvas fields the platform writes on
save/open that aren't needed when creating a drawing via the API: a root "comments":
[] array, a per-canvas "pdfExport" (mirrors the root-level one described below —
UI dialog state, not required), a per-canvas "s3d" object holding unrelated UI-dismiss
flags (e.g. auto_schedule_table_dismissed, distinct from the root s3d structural
mapping described above), grouping metadata arrays (points_group, edges_group,
sections_group), and a "canvas_group" object (role, group_id,
parent_canvas_id, color_id) describing multi-canvas relationships. Safe to omit
these when constructing cad_data from scratch — they default correctly — but don't
be alarmed if they appear when you cloudcad.file.open an existing drawing and read
its JSON back.
Canvas Element Types
Points
{ "x": 100, "y": 200, "id": "uuid" }id is optional — auto-generated if omitted.
Lines
A straight segment between two points.
{
"p1": { "x": 0, "y": 0 },
"p2": { "x": 1000, "y": 0 },
"id": "uuid",
"groupId": "uuid"
}To form a closed polygon, give multiple lines the same
groupIdand ensure their endpoints connect.
Polylines
Circle
{
"type": "circle",
"center": { "x": 0, "y": 0 },
"radius": 500,
"radiusPoint": { "x": 500, "y": 0 },
"segments": 100,
"id": "uuid"
}Arc
Defined by start, end, and a control point on the arc.
{
"type": "arc",
"points": [
{ "x": 0, "y": 0 },
{ "x": 100, "y": 100 },
{ "x": 50, "y": 80 }
],
"segments": 100,
"id": "uuid"
}Dimensions (Linear)
Image: Linear dimension anatomy: p1/p2 mark the measured segment, offsetPoint sets how far the dimension line floats and where its value text sits
{
"p1": { "x": 0, "y": 0 },
"p2": { "x": 1000, "y": 0 },
"offsetPoint": { "x": 500, "y": 200 },
"id": "uuid",
"projectionType": "horizontal",
"attributeStyleId": "as-default"
}projectionType: "vertical", "horizontal", or omit for auto.
Always include attributeStyleId so arrow and text sizes are correct.
Only horizontal/vertical projections are supported — passing
p1/p2for a tilted (non-axis-aligned) measurement silently falls back to a non-tilted dimension with the wrong value, instead of erroring. Confirmed the hard way building an MT Solar rail-length dimension along a tilted panel. To dimension a true diagonal/tilted distance, don't use this entity — build it from primitives instead: two shortleaderTextextension ticks (style"as-plain-ext"for no arrowhead) off the two measured points, projected out perpendicular to the tilt, plus aleaderTextdimension line parallel to the tilt with a value label you compute and format yourself (so it always matches the real geometry, since nothing here calculates it for you).
Angle Dimensions
Measures the angle between two lines that share a common vertex. Confirmed from a real platform-exported file.
Image: Angle dimension anatomy: l1 and l2 share the intersection vertex, p sets both the arc radius and the label position
{
"l1": {
"p1": { "x": -5980, "y": -2400 },
"p2": { "x": -7260, "y": -680 }
},
"l2": {
"p1": { "x": -8360, "y": -2400 },
"p2": { "x": -5980, "y": -2400 }
},
"intersection": { "x": -5980, "y": -2400 },
"p": { "x": -5760, "y": -1060 },
"id": "uuid",
"attributeStyleId": "as-default"
}l1/l2: the two lines forming the angle, each a{p1, p2}pair. One endpoint ofl1and one endpoint ofl2must equalintersection— the shared vertex the angle is measured at.intersection: the vertex point shared by both lines.p: where the angle arc and its label are drawn — a point out from the vertex, roughly between the sweep of the two lines. Analogous tooffsetPointon a linear dimension.- Always include
attributeStyleId— the style'sangleArrowShape,angleDimensionTextSize,angleTextOffset, andangleTextOrientationfields control its display.
Three non-obvious behaviors, confirmed building a tilt-angle dimension for an MT Solar elevation:
p's distance fromintersectionsets the arc's radius — CloudCAD draws the arc, and each ray's extension tick, out top's distance from the vertex, not out tol1/l2's ownp2endpoints. If you want a ray's tick to land exactly on a real geometry point (e.g. a panel corner), setp's distance fromintersectionequal to that point's distance fromintersection— don't just eyeballp's position.- Sweep direction depends on which way
l1points, not just its angle. Swappingl1's ray to point the opposite way (same line, reversed) swept the arc through the supplement of the intended angle (e.g.180° - tiltinstead oftilt) even thoughl2andintersectionwere unchanged.l1needs to point the same rotational way asl2's sweep for the drawn angle to match the real one.- Anchor at least one ray to a real geometry point, not a virtual/constructed one — otherwise the dimension doesn't visually read as connecting to anything. If neither line's other endpoint is naturally a real point, compute
intersectionby projecting back from a real point along its true line/slope (not by dropping it straight down or across), so the ray's far endpoint stays exact.
Radius Dimensions
Present in the canvas schema ("radiusDimensions": []) and accepted in the attributeStyleId list, but no populated example has been found in a live export yet — both assets/all-elements.json and assets/Title-Block-Example.json show it only as an always-empty array. Don't guess this element's field structure (see the "Never scale model geometry..." warning above for why this skill treats unverified schema as a real risk, not a formality). Before generating one programmatically, round-trip test it: create a radius dimension manually in the CloudCAD UI, save, cloudcad.file.open it back, and read the resulting JSON to confirm the real field names.
Leader Texts
An arrow pointing from a location to a text label.
{
"startPoint": { "x": 0, "y": 0 },
"endPoint": { "x": 200, "y": 100 },
"text": "Column C1",
"id": "uuid",
"attributeStyleId": "as-default"
}Multi-Leader Texts
Text annotation with multiple arrow leaders.
{
"anchorPoint": { "x": 0, "y": 0 },
"arrowPoints": [
{ "x": -100, "y": -50 },
{ "x": 100, "y": 50 }
],
"text": "Structural Note",
"id": "uuid",
"attributeStyleId": "as-default"
}Texts
{
"position": { "x": 100, "y": 200 },
"text": "My Label",
"size": 14,
"color": "#ffffff",
"backgroundColor": "#000000",
"backgroundColorOpacity": 0,
"alignment": "center",
"textPosition": "middle-center",
"rotation": 0,
"bold": false,
"italic": false,
"id": "uuid",
"attributeStyleId": "as-default"
}rotation is in degrees (confirmed from a real export). A real export also carries computed layout fields (boxWidth, boxHeight, boxMinHeight, start_pos, end_pos, totalWidth, totalHeight) — these are derived by the platform from text/size/position and can be omitted when creating a text element programmatically.
alignment: "left", "center", "right".textPosition (required — omitting it will crash selection): "top-left", "top-center", "top-right", "middle-left", "middle-center", "middle-right", "bottom-left", "bottom-center", "bottom-right". Default to "middle-center".backgroundColorOpacity: 0 = transparent, 1 = opaque.size is in pixels — use 14 for body text, 20–28 for headings. The attributeStyleId can override this if textSizeOverride is enabled on the style.
CRITICAL — text color: The canvas background is dark. Always set
colorto a light value ("#ffffff"for headings,"#e2e8f0"for body,"#94a3b8"for secondary labels). Never use"#333333","#222222","#000000", or any other dark/black color — dark text is invisible on the dark canvas and cannot be read by the user.
alignment: "center"/"right"double-compensates if you've already positioned the text yourself. Confirmed by measuring a rendered title against its true geometric center: the platform applies its own additional horizontal shift on top of whateverpositionyou supply wheneveralignmentis"center"or"right"— it isn't a pure "anchor the box this way" flag. If you're computingpositionyourself (e.g. to center a title over a drawing), the reliable pattern is to estimate the text's rendered width, shiftposition.xby that estimate yourself, and always emitalignment: "left"— never let the platform apply a second shift on top of your own. A rough width estimator that's held up across several re-measured strings:renderedWidth ≈ text.length * size * 16(in the same mm-like units asposition).
Tables
{
"id": "uuid",
"attributeStyleId": "as-default",
"position": { "x": 0, "y": 0 },
"title": "MY CUSTOM TABLE",
"rows": [
["Header 1", "Header 2", "Header 3"],
["Cell 1", "Cell 2", "Cell 3"]
],
"opts": {
"first_row_header": true,
"alignment": "center",
"text_color": "#ffffff",
"bg_color": "#000000",
"header_background_color": "#4a5568",
"font_size": 15,
"width": 2000,
"height": 800,
"row_height": 200
}
}title (optional, confirmed from a real export) renders as a caption above the table.
Axes (Gridlines)
A labeled reference axis/gridline between two points.
Image: Axis dash-dot line pattern set by axisDashLength and axisDashGap, with the label circle at the terminus
{
"p1": { "x": 0, "y": -5000 },
"p2": { "x": 0, "y": 5000 },
"label": "A",
"id": "uuid",
"attributeStyleId": "as-default"
}Axes always render as a dash-dot line (the standard convention for gridlines/
centerlines) — the dash length and gap come from the referenced style's
axisDashLength / axisDashGap (see "attributeStyles" above), not from a per-element
field.
Construction Lines
Infinite reference lines defined by a point and angle.
{
"point": { "x": 0, "y": 0 },
"angle": 90,
"id": "uuid",
"isHidden": false,
"lineType": "dashdotdot"
}angle is in degrees. lineType (optional, confirmed from a real export) accepts the
same values as a Layer's lineType (see "Layers" below) — e.g. "dashdotdot" for a
centerline convention — and overrides the layer default for this element.
Revision Clouds
Image: Revision cloud bounding-box fields: rectangular uses minX/minY/maxX/maxY, circular uses center/radius
Rectangular
{
"id": "uuid",
"minX": 0, "minY": 0,
"maxX": 1000, "maxY": 500,
"arcRadius": 500,
"segments": 10,
"arcs": []
}Circular
{
"id": "uuid",
"minX": 0, "minY": 0,
"maxX": 1000, "maxY": 1000,
"arcRadius": 500,
"segments": 10,
"center": { "x": 500, "y": 500 },
"radius": 500,
"arcs": []
}Provide the bounding box and
arcRadius; the renderer computes thearcsarray automatically. Passarcs: []when creating programmatically.
Hatches
A filled region defined by one or more closed loops. Each loop is an array of segments.
{
"id": "uuid",
"type": "hatch",
"color": "#5a5995",
"opacity": 0.5,
"loops": [
{
"segments": [
{ "type": "line", "start": { "x": 0, "y": 0 }, "end": { "x": 100, "y": 0 } },
{ "type": "line", "start": { "x": 100, "y": 0 }, "end": { "x": 100, "y": 100 } },
{ "type": "line", "start": { "x": 100, "y": 100 }, "end": { "x": 0, "y": 0 } }
]
}
]
}Segment types: "line" or "arc". Loops must be closed (last segment endpoint = first segment start point).
A real export also carries "pattern" (a named fill pattern, e.g. "stone") and "patternScale" alongside "color"/"opacity" — both optional, omit for a solid fill at default scale.
Images
Images are stored as base64 text. See below example
{
"id": "5776f8ac-a865-439e-99f1-2113c156e6fc",
"src": "data:image/png;base64,iVBO...",
"x": 3686.8526586590224,
"y": -8875.987027389341,
"width": 1650,
"height": 1173,
"rotation": 0,
"opacity": 1,
"z": 1,
"isPdf": false,
"isRenderer": false,
"s3dRender": null
}x/y is the image's top-left corner (not a center), width/height in mm — for a
square source image, set them equal to draw it undistorted. A production generator
instead used isPdf/pdfName/pdfPage in place of isRenderer/s3dRender (for
embedding a specific page of a PDF) — both variants have been seen working; include
whichever pair matches what you're embedding, isPdf: false with the rest omitted is
fine for a plain raster image.
imagesis canvas-level only — it is NOT a supported item type inside ablockReferences[].itemsblock definition (see "Blocks" below; the supported item types there don't includeimage, and a real platform-exported title block confirms this the hard way — its own logo slot is a plain text placeholder reading"LOGO PLACEHOLDER", not an embedded image, presumably for this exact reason). If you're reusing the block-based title-block template (see "Pages & Title Blocks" below) and need a real logo image in it, don't try to nest the image inside the block — instead, push a separate entry onto the canvas's own top-levelimagesarray, positioned (x/y/width/height) to land in the same spot the block's placeholder occupies. A production generator does exactly this: it skips the block/instance system for its title block entirely and draws the logo, and everything else in the block, straight onto the canvas (lines/texts/tables/images) at computed absolute coordinates.
Blocks
Reusable drawing element groups — used for anything you place more than once (a repeated detail, a north-point symbol, or a title block, see "Pages & Title Blocks" below).
Block References (Definitions)
Top-level, camelCase, sibling of canvases — cad_data.blockReferences, an array.
This is a real correction to this schema: block definitions do not live inside a
canvas. Canvases only place an already-defined block via block_instances (below).
Verified against the live API and a genuine platform-exported project file.
{
"id": "block-def-uuid",
"name": "Detail A",
"basePoint": { "x": 0, "y": 0 },
"items": [
{ "type": "line", "data": { "p1": { "x": 0, "y": 0 }, "p2": { "x": 100, "y": 100 } } },
{ "type": "arc", "data": { "type": "arc", "points": [ ... ], "segments": 100 } },
{ "type": "dimension", "data": { "p1": { ... }, "p2": { ... }, "offsetPoint": { ... } } },
{ "type": "multiLeaderText", "data": { "anchorPoint": { ... }, "arrowPoints": [ ... ], "text": "Note" } },
{ "type": "hatch", "data": { "color": "#5a5995", "opacity": 0.5, "loops": [ ... ] } },
{ "type": "point", "data": { "x": 10, "y": 20 } },
{ "type": "text", "data": { "position": { "x": 0, "y": 0 }, "text": "Label", "size": 14, "color": "#ffffff", "textPosition": "middle-center", "backgroundColorOpacity": 0 } },
{ "type": "leaderText", "data": { "startPoint": { ... }, "endPoint": { ... }, "text": "Note" } }
]
}Supported item types inside blocks: point, line, arc, dimension, multiLeaderText,
hatch, text, leaderText (the last two confirmed from a real title-block asset, not
previously documented here). image is not one of them — see the "Images" note above
for the canvas-level workaround (a real title block even uses a "LOGO PLACEHOLDER" text
item where a logo would go, instead of an embedded image).
basePoint is the anchor: it's the point in the block's own local geometry that gets
mapped onto position when the block is instanced (see the transform below) — it is
not necessarily the block's bounding-box corner. In practice, set it to whatever
point in your block's geometry makes the most sense as an insertion handle (e.g. its
centroid, or a specific corner).
Block Instances
Place a block on a canvas.
Image: Block placement transform: local geometry maps to world space via position, scale, and basePoint
{
"id": "instance-uuid",
"blockId": "block-def-uuid",
"position": { "x": 0, "y": 0 },
"rotation": 0,
"scale": { "x": 1, "y": 1 }
}Placement transform (rotation = 0): every point local in the block definition's
items maps to world/canvas space as:
world.x = instance.position.x + instance.scale.x * (local.x - blockRef.basePoint.x)
world.y = instance.position.y + instance.scale.y * (local.y - blockRef.basePoint.y)(With rotation != 0, apply a standard 2D rotation about basePoint before scaling and
translating — not covered by the simple formula above.)
Layers
Assign elements to layers for color, visibility, and line-type control.
{
"id": "layer-uuid",
"name": "Structural",
"color": "#9ef5af",
"visible": true,
"locked": false,
"lineThickness": 2,
"lineType": "solid",
"patternScale": 1,
"items": [
{ "type": "line", "id": "line-uuid" },
{ "type": "circle", "id": "polyline-uuid" }
]
}lineType: "solid", "dashed", "dashdotdot" (this last one confirmed from a real
CloudCAD export, on a constructionLines entity — a common drafting convention for
centerlines).
A
constructionLinesexport also showedlineTypeset directly on the element itself, not only via itsLayer— i.e.{ "point": {...}, "angle": 90, "lineType": "dashdotdot" }. Whether an ordinary boundedline/polyline(as opposed to an infinite construction line) also respects a per-elementlineTypethe same way is a same-schema bet, not independently confirmed — round-trip test it (create one with the field set in the CloudCAD UI, save,cloudcad.file.openit back) before relying on it for anything that must render correctly unattended.
pdfExport (Pages)
Top-level, sibling of canvases — cad_data.pdfExport. Defines the physical
printed page(s) for the drawing: a rectangle in canvas units overlaid on the canvas,
plus paper metadata. Previously undocumented; confirmed against a real platform-exported
project.
{
"pdfPages": [
{
"frame": {
"start": { "x": 67000, "y": -105000 },
"end": { "x": 126400, "y": -63000 }
},
"orientation": "landscape",
"format": "A2",
"printPage": true,
"offset": { "top": 0, "right": 0, "bottom": 0, "left": 0 },
"scale": 100,
"canvasIndex": 0
}
]
}| Key | Type | Description |
frame.start / frame.end | {x,y} | The page's rectangle in canvas units (respects settings.canvasLengthUnits) — this is the page; format/orientation are descriptive labels and must be kept consistent with it, not the other way round. |
orientation | string | "landscape", "portrait" |
format | string | Paper size label, e.g. "A0"–"A4" |
printPage | boolean | Whether this page is included in a PDF export |
offset | {top,right,bottom,left} | Print margins |
scale | number | Print scale, percent |
canvasIndex | integer | Which canvases[] entry this page belongs to (for multi-canvas documents) |
Compute the frame size from the paper format in mm, e.g. A2 landscape = 594mm × 420mm →
594 * 100 = 59400 units wide, 420 * 100 = 42000 units tall (the example above uses
that exact size). A savedSettings sibling key may also appear alongside pdfPages —
that's UI dialog state (last-used format/margins in the CAD editor), safe to omit when
creating a drawing programmatically.
Pages & Title Blocks — Default Template
Do this by default. Unless the user asks for bare geometry only (or explicitly says they don't want a title block/page), every CAD drawing you generate should be wrapped in this page + title block template. It's easy for a user to strip back out afterward — delete the
blockReferences,pdfExport, and the title-blockblock_instancesentry — so default to including it rather than asking first.
To produce a drawing that looks like a finished, ready-to-print sheet (a page border +
title block, not just bare geometry), reuse the ready-made template at
assets/Title-Block-Example.json rather than
building one from scratch — it's a real, working A2-landscape page + title block
exported from the platform. Copy these three pieces verbatim into your new cad_data:
pdfExport— the A2-landscape page frame (see above).blockReferences[0]— the title block's own definition (border lines, the info table, labels like "Project Title:", "Project Address:", "STATUS:"). Keep itsid.- The canvas's
block_instances[0]— places that block atposition: {x: 96700, y: -86048},scale: {x: 2, y: 2},rotation: 0, referencing theblockIdfrom step 2.
Want a real logo instead of the template's
"LOGO PLACEHOLDER"text? Don't edit it into the block —imageisn't a supported block item type (see "Images" above). Add it as its own entry in the canvas's top-levelimagesarray instead, withx/y/width/heightcomputed to land in the same spot, alongside your own drawing content below.
Then add your own drawing content (lines, dimensions, texts) to the canvas, translated only to sit inside the page frame without overlapping the title block:
1. Compute the new content's bounding box: [contentMinX, contentMaxX] x [contentMinY, contentMaxY]
2. Define a safe drawing rectangle inside the page frame, clear of the title block
(see below for this template specifically)
3. Translate every coordinate in your content by (safeCenter - contentCenter) so its
bounding-box center lands on the safe rectangle's center - do NOT scale/resize itNever scale model geometry to force-fit a page — this is a real mistake this skill made once, do not repeat it. CAD model coordinates are the true, real-world measurement of what's drawn; CloudCAD's
dimensionsreport the actual distance between their two points, so scaling geometry to fit a page silently corrupts every dimension label along with it (a 24 ft span rendered as "40000mm" instead of the true 7315.2mm, because the whole drawing had been scaled up ~5.5x to visually fill the page). Draw everything at true size and only translate (reposition) it. If true-size content is smaller than the page at this template's plot scale, that's correct — the object is just small relative to the sheet, the same as it would be on a real drafter's A2 sheet at this scale. If you need the object to visually fill more of the page, that is a plot-scale problem (use a title-block/page template built for a finer scale, e.g. 1:20 instead of this one's ~1:100 — see "Known limitations"), never a "stretch the model" problem.
settings.canvasLengthUnitsis display-only — it does NOT reinterpret what stored x/y numbers mean, so never rescale coordinates when changing it. Raw coordinates are real mm internally regardless of this setting; changing it only changes how dimension labels are converted for display when read back. If you pre-divide every coordinate by 304.8 to "convert to feet" and also setcanvasLengthUnits: "ft", you double convert: the geometry becomes 304.8x too small, and then that already-wrong tiny value gets converted again for the label (a real 24 ft span became 24mm internally, then displayed as "0.08 ft" — exactly 24/304.8). This also breaks a reused title block the same way (its textsizefields are untouched scalars while its position coordinates get incorrectly shrunk, so its text ends up dwarfing its own shrunken border). To change the displayed unit, only ever change thecanvasLengthUnitssetting itself — build all geometry in true real mm exactly as described above, regardless of what unit you want dimension labels to read in.
For this exact template (A2 landscape), analysis of the title block's own geometry
shows its info table (the actual text fields) occupies roughly the right half of the
page, spanning most of its height — not just a bottom strip. As a conservative starting
default, treat the left ~45,000 units of page width (roughly x: 69000 to x:
114000, y: -103000 to -65000, leaving margins) as the safe zone for new drawing
content, and keep the title block itself untouched on the right.
Known limitations — read before assuming this "just works"
- This safe-zone rectangle is an approximation, derived by analyzing the block's
coordinate data, not by visually rendering the drawing (no tool available here can
render/screenshot the CAD viewer). It's a reasonable starting default, not a
pixel-verified boundary. The first time you use this pattern on a new project, open
the returned
view_linkand visually confirm nothing overlaps the title block before trusting it for unattended/repeated use. - Only cleanly reusable at A2 landscape, or other ISO 'A' landscape sizes via uniform
rescaling (A0/A1/A3/A4 landscape all share the same √2:1 aspect ratio as A2, so
scaling
pdfExport.frame, the block'sposition, and itsscaleby the same factor keeps everything proportional). Portrait orientation, or non-ISO sizes (e.g. ANSI D/E), are not trivially derived from this template — the title block's artwork (line lengths, text positions) is fixed, hand-drafted geometry, not a parametric layout, so a different aspect ratio needs its own template rather than a stretch of this one (stretching non-uniformly will visibly distort the border and text). - Rotated placement isn't covered by the simple placement formula above — this
template uses
rotation: 0.
cloudcad.model Functions
cloudcad.model.create
Creates a new CAD model from a cad_data object. Must be called before cloudcad.file.save.
{
"function": "cloudcad.model.create",
"arguments": {
"cad_data": {
"settings": { "canvasLengthUnits": "mm" },
"blockReferences": [],
"canvases": [
{
"version": "2.0.0",
"schema": "canvas-json-v2-optimized",
"name": "Floor Plan",
"drawing_type": "Plan",
"is_base": true,
"points": [],
"lines": [
{ "p1": { "x": 0, "y": 0 }, "p2": { "x": 5000, "y": 0 } }
],
"polylines": [],
"dimensions": [],
"angleDimensions": [],
"radiusDimensions": [],
"leaderTexts": [],
"multiLeaderTexts": [],
"texts": [],
"tables": [],
"axes": [],
"constructionLines": [],
"revisionClouds": [],
"hatches": [],
"images": [],
"block_instances": [],
"layers": []
}
]
}
}
}Response:
{ "status": 0, "msg": "CAD model was successfully created.", "data": "" }cloudcad.file Functions
cloudcad.file.save
Save the current CAD model to cloud storage. Requires cloudcad.model.create earlier in the session.
| Key | Type | Description |
name | string | File name |
path | string | Cloud storage path |
public_share | boolean | Also return a public view-only link |
return_uid_url | boolean | Return a UID-based URL (?u=) instead of name/path URL |
{
"function": "cloudcad.file.save",
"arguments": {
"name": "floor-plan-v1",
"path": "projects/cad/",
"public_share": true
}
}Response:
{
"status": 0,
"msg": "CAD model was successfully saved ...",
"data": "https://platform.skyciv.com/cad?preload_name=floor-plan-v1&preload_path=projects/cad/",
"public_link": "https://platform.skyciv.com/cad-viewer?project_id=..."
}cloudcad.file.open
Load a CAD model from cloud storage.
| Key | Type | Description |
name | string | File name |
path | string | Cloud storage path |
uid | string | File UID (alternative to name/path) |
{
"function": "cloudcad.file.open",
"arguments": {
"name": "floor-plan-v1",
"path": "projects/cad/"
}
}Response:
{ "status": 0, "msg": "File Loaded: CAD model 'floor-plan-v1' is set." }Full Example — Create and Save a CAD Drawing
{
"auth": { "username": "user@example.com", "key": "YOUR_KEY" },
"options": { "validate_input": true },
"functions": [
{
"function": "S3D.session.start",
"arguments": { "keep_open": false }
},
{
"function": "cloudcad.model.create",
"arguments": {
"cad_data": {
"settings": { "canvasLengthUnits": "mm" },
"attributeStyles": [
{
"id": "as-default",
"name": "Default Style",
"settings": {
"linearArrowShape": "arrow",
"linearArrowLength": 216, "linearArrowWidth": 216,
"linearExtLineStartOffset": 0, "linearExtLineEndOffset": 0,
"linearTextOffset": 0, "linearTextHorizontalOffset": 0,
"linearTextHorizontalPosition": "center",
"dimensionTextSize": 378,
"angleArrowShape": "arrow",
"angleArrowLength": 216, "angleArrowWidth": 216,
"angleDimensionTextSize": 378,
"angleTextOffset": 600, "angleTextOrientation": "horizontal",
"radiusArrowShape": "arrow",
"radiusArrowLength": 216, "radiusArrowWidth": 216,
"radiusDimensionTextSize": 378, "radiusTextOffset": 0,
"leaderArrowShape": "arrow",
"leaderArrowLength": 216, "leaderArrowWidth": 216,
"leaderTextSize": 378,
"leaderTextOffsetHorizontal": 0, "leaderTextOffsetVertical": 0,
"axisExtension": 5000, "axisCircleDiameter": 1080,
"axisTextSize": 324, "axisDashLength": 216, "axisDashGap": 108,
"textSizeInput": 14, "textSizeOverride": false,
"fontFamily": "monospace", "tableFontSize": 400
}
}
],
"canvases": [
{
"version": "2.0.0",
"schema": "canvas-json-v2-optimized",
"name": "Ground Floor Plan",
"drawing_type": "Plan",
"is_base": true,
"points": [],
"lines": [
{ "p1": { "x": 0, "y": 0 }, "p2": { "x": 6000, "y": 0 }, "groupId": "g1" },
{ "p1": { "x": 6000, "y": 0 }, "p2": { "x": 6000, "y": 4000 }, "groupId": "g1" },
{ "p1": { "x": 6000, "y": 4000 }, "p2": { "x": 0, "y": 4000 }, "groupId": "g1" },
{ "p1": { "x": 0, "y": 4000 }, "p2": { "x": 0, "y": 0 }, "groupId": "g1" }
],
"polylines": [],
"dimensions": [
{
"p1": { "x": 0, "y": 0 },
"p2": { "x": 6000, "y": 0 },
"offsetPoint": { "x": 3000, "y": -500 },
"attributeStyleId": "as-default"
}
],
"angleDimensions": [], "radiusDimensions": [],
"leaderTexts": [], "multiLeaderTexts": [],
"texts": [
{
"position": { "x": 3000, "y": 2000 },
"text": "GROUND FLOOR",
"size": 20,
"color": "#ffffff",
"alignment": "center",
"textPosition": "middle-center",
"bold": true,
"italic": false,
"backgroundColor": "#000000",
"backgroundColorOpacity": 0,
"attributeStyleId": "as-default"
}
],
"tables": [], "axes": [], "constructionLines": [],
"revisionClouds": [], "hatches": [], "images": [],
"block_instances": [], "layers": []
}
]
}
}
},
{
"function": "cloudcad.file.save",
"arguments": {
"name": "ground-floor-plan",
"path": "projects/building-a/",
"public_share": true
}
}
]
}Coordinate System
- All coordinates are 2D:
x(horizontal) andy(vertical) on the canvas. yis up as negative! So you need to reverse the direction if you're trying to build something upwards- Units are controlled by
settings.canvasLengthUnits. - There is no Z axis on a single canvas; elevation is represented by using multiple canvases at different elevations (configured in
s3d.elevations). - Coordinates can be any number including negative — the canvas has no fixed origin boundary.
Key Patterns
Closed polygon from lines: Share the same groupId across connected line segments.
Reusable details: Define once in the top-level blockReferences, place many times via block_instances with different position, rotation, and scale.
Organised drawings: Assign elements to layers by referencing their type and id. Enable displayColorByLayers in settings to inherit layer colors.
Opening a previously saved drawing for editing: Use cloudcad.file.open to load it into the session, modify via API, then cloudcad.file.save with the same name/path to overwrite.
The z field: most element types (lines, dimensions, axes, tables, block_instances, hatches, ...) carry a "z" integer in a real export — an internal render/stacking-order index the platform assigns on save. Safe to omit when creating elements programmatically; don't try to control draw order with it.
Sizing, Units and Scaling
Always define attributeStyles and reference "attributeStyleId": "as-default" on every annotation element (dimensions, texts, leader texts, axes). Without this, annotation sizes default to values designed for a different drawing scale and will look wrong.
Scale all length values in the attribute style to match the drawing size:
| Drawing scale | Typical geometry size | dimensionTextSize | linearArrowLength | textSizeInput |
| Cross-section | 50–300 mm | 10 | 6 | 14 |
| Structural detail | 200–2000 mm | 50 | 30 | 14 |
| Building (rooms) | 3000–10000 mm | 378 | 216 | 14 |
| Large building / site | 10000–50000 mm | 500 | 300 | 14 |
For any drawing larger than 5000 mm, compute the text size proportionally instead of guessing from the table:
dimensionTextSize = Math.round(Math.max(buildingWidth, buildingHeight) / 60)
linearArrowLength = Math.round(dimensionTextSize * 0.6)
linearArrowWidth = linearArrowLengthExamples: 10 000 mm building → 167 mm text, 30 000 mm → 500 mm text, 50 000 mm → 833 mm text.
Apply the same formula to angleDimensionTextSize, radiusDimensionTextSize, leaderTextSize, and axisTextSize.
textSizeInput is in pixels and does not scale with geometry — keep it at 14 for body text, 20–28 for headings regardless of drawing scale.
textPosition is required on every text element. Omitting it causes a crash when the user tries to select items. Default to "middle-center".
Integration with other tools
If you're on the SkyCiv platform (i.e. hosted on platform.skyciv.com) you can use SKYCIV_UTILS.exportToCad(cad_data) to launch a CAD file from another product. This is helpful if you are auto-generating drawings from another SkyCiv product. This is not available on prototypes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

