CAD Overview
Overview#
This set of functions allows you to build and save CloudCAD files using SkyCiv's CAD software.
Top-Level Structure#
attributeStyles,blockReferences, andpdfExportare top-level fields, siblings ofcanvases- not nested inside a canvas object.
settings#
Controls display, snapping, colors, dimensions, and units. All fields are optional โ defaults are applied for any omitted values.
| Key | Type | Description |
|---|---|---|
canvasLengthUnits | string | Length unit: "mm", "cm", "m", "ft", "in" |
gridSize | string | Grid spacing value |
snapToGrid | bool | Snap cursor to grid |
snapToPoint | bool | Snap to existing points |
snapToLineEnds | bool | Snap to line endpoints |
snapToLineMid | bool | Snap to line midpoints |
snapToAlign | bool | Snap to alignment guides |
snapToAxis | bool | Snap to axes |
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 color for canvas background |
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 scale for dimension display |
globalTextScale | string | Global scale for text display |
arcSegments | string | Segment count for arc rendering |
circleSegments | string | Segment count for circle rendering |
Full settings object can include many more display/snap/color options. Omit any you don't need โ sensible defaults are used.
s3d (Structural 3D Settings)#
Optional. Used when the CAD drawing maps to a structural model.
canvases#
Array of canvas (drawing) objects. Each canvas contains all the geometry, annotations, and metadata for one drawing sheet.
Block definitions are not a canvas field (see
blockReferencesat the top level, under "Blocks") - a canvas only places a block viablock_instances.
Canvas Element Types#
Points#
Lines#
A straight segment between two points.
Tip: To create a closed polygon, create multiple lines that share endpoints and assign the same
groupId.
Polylines โ Circle#
Polylines โ Arc#
Defined by three points: start, end, and a mid/control point on the arc.
Dimensions (Linear)#
Leader Texts#
An arrow from a point to a text label.
Multi-Leader Texts#
A text annotation with multiple arrow leaders.
Texts#
Tables#
Axes (Gridlines)#
A labeled axis/gridline between two points.
Construction Lines#
Infinite reference lines defined by a point and angle (in degrees).
Revision Clouds โ Rectangle#
Rectangular revision cloud defined by bounding box.
Revision Clouds โ Circular#
The
arcsarray is typically auto-generated. When creating revision clouds programmatically, provide the bounding box (minX,minY,maxX,maxY) andarcRadiusโ the renderer will compute the scallop arcs.
Hatches#
A filled region defined by one or more closed loops.
Each loop is a closed boundary. Segments within a loop can be "line" or "arc" types.
Blocks#
Blocks allow you to define reusable groups of drawing elements - used for anything placed more than once, including a title block (see "Pages & Title Blocks" below).
Block References (Definitions)#
Top-level field, camelCase: blockReferences (a sibling of canvases, not nested
inside one). A canvas only places a block via block_instances - it never defines one
itself.
Supported item types inside a block: point, line, arc, dimension, multiLeaderText, hatch, text, leaderText.
basePoint is the local-space point that maps onto a placed instance's position - not
necessarily the block's bounding-box corner.
Block Instances#
Place a block definition on a canvas with position, rotation, and scale.
Placement transform (rotation = 0): a point local in the block definition maps to
canvas space as world = position + scale * (local - basePoint) (component-wise on x/y).
With rotation != 0, apply a 2D rotation about basePoint before scaling/translating.
Layers#
Assign canvas items to layers for organization, color, and visibility control.
Items reference elements by their type and id. When displayColorByLayers is enabled in settings, items inherit the layer color.
pdfExport (Pages)#
Top-level field, sibling of canvases: pdfExport.pdfPages[] defines the physical
printed page(s) - a rectangle in canvas units overlaid on the canvas, plus paper metadata.
frame.start/frame.end is the page - format/orientation are descriptive labels
that must stay consistent with it. Compute the frame from the paper size in mm x 100
(e.g. A2 landscape = 594mm x 420mm -> 59400 x 42000 units, as above). A sibling
savedSettings key may also appear - that's CAD editor UI state, safe to omit when
creating a drawing programmatically.
Pages & Title Blocks#
To produce a finished, print-ready sheet (a page border + title block, not bare
geometry), reuse the ready-made template at assets/Title-Block-Example.json - a real
A2-landscape page + title block exported from the platform - rather than building one
from scratch. Copy its pdfExport, its blockReferences[0] (the title block
definition), and the canvas's block_instances[0] (which places it at position:
{x:96700, y:-86048}, scale: {x:2, y:2}) into a new cad_data, then add your own
drawing content scaled/centered to fit the page without overlapping the title block.
This template is only cleanly reusable at A2 landscape, or other ISO 'A' landscape sizes
via uniform rescaling (they share the same aspect ratio) - portrait or non-ISO formats
need their own template, since the title block's geometry is fixed artwork, not a
parametric layout. See cloudcad-api/SKILLS.md's "Pages & Title Blocks" section for the
full reuse pattern and its known limitations.
Minimal Example#
A simple drawing with one line and one circle:
Sending Data to CAD from other pages#
From anywhere on the SkyCiv platform, you can open CAD with pre-built drawing data using:
Where cad_data is a JSON object following the schema described below.