cloudcad.export


The cloudcad.export namespace exports the CloudCAD drawing in the current session to other file formats.


cloudcad.export.pdf#

Export the current CloudCAD drawing as a PDF and return a link to download it.

important

cloudcad.model.create must be called earlier in the session, so there is a drawing to export.

By default, the pages and PDF settings come from the pdfExport object in the cad_data passed to cloudcad.model.create:

  • pdfExport.pdfPages defines the pages to print. It must be defined, either in the drawing or in the pdfPages argument below.
  • pdfExport.savedSettings controls the PDF settings.

Both can be overridden for a single export by passing them as arguments. All arguments are optional, so "arguments": {} exports the drawing as it is set up.

KeyTypeDescription
qualitynumberRender quality of the PDF. Defaults to 4.
pdfPages[object]Pages to export. Overrides pdfExport.pdfPages in the drawing. See Page objects.
savedSettingsobjectPDF settings. Overrides pdfExport.savedSettings in the drawing.

Page objects#

Each entry in pdfPages describes one printed page.

KeyTypeDescription
frameobjectThe page rectangle in canvas millimetres, as { "start": { "x", "y" }, "end": { "x", "y" } }. Remember that y is negative going up.
formatstringPaper size, "A0" to "A4". Keep it consistent with the size of frame.
orientationstring"landscape" or "portrait".
printPagebooleanInclude this page in the export.
offsetobjectPrint margins, as { "top", "right", "bottom", "left" }.
scalenumberPlot scale denominator, for example 100 for 1:100.
canvasIndexnumberIndex of the canvas in canvases that the page prints.

Export using the pages and settings stored in the drawing:

Sample input for cloudcad.export.pdf
{
"function": "cloudcad.export.pdf",
"arguments": {}
}

Export a single A4 landscape page at 1:100 at a higher quality, overriding the drawing's pages:

Sample input for cloudcad.export.pdf (override pages)
{
"function": "cloudcad.export.pdf",
"arguments": {
"quality": 6,
"pdfPages": [
{
"frame": { "start": { "x": -11850, "y": -12500 }, "end": { "x": 17850, "y": 8500 } },
"orientation": "landscape",
"format": "A4",
"printPage": true,
"offset": { "top": 0, "right": 0, "bottom": 0, "left": 0 },
"scale": 100,
"canvasIndex": 0
}
]
}
}

cloudcad.model.create and cloudcad.export.pdf can be sent in the same request:

Sample request
{
"auth": {
"username": "YOUR_SKYCIV_USERNAME",
"key": "YOUR_SKYCIV_API_KEY"
},
"functions": [
{
"function": "cloudcad.model.create",
"arguments": {
"cad_data": {
"settings": { "canvasLengthUnits": "mm" },
"pdfExport": {
"pdfPages": [
{
"frame": { "start": { "x": -11850, "y": -12500 }, "end": { "x": 17850, "y": 8500 } },
"orientation": "landscape",
"format": "A4",
"printPage": true,
"offset": { "top": 0, "right": 0, "bottom": 0, "left": 0 },
"scale": 100,
"canvasIndex": 0
}
]
},
"canvases": [
{
"name": "Ground Floor",
"lines": [
{ "p1": { "x": 0, "y": 0 }, "p2": { "x": 6000, "y": 0 } },
{ "p1": { "x": 6000, "y": 0 }, "p2": { "x": 6000, "y": -4000 } },
{ "p1": { "x": 6000, "y": -4000 }, "p2": { "x": 0, "y": -4000 } },
{ "p1": { "x": 0, "y": -4000 }, "p2": { "x": 0, "y": 0 } }
]
}
]
}
}
},
{
"function": "cloudcad.export.pdf",
"arguments": {}
}
]
}

On success, data.download_link is a link to view or download the PDF:

Sample response for cloudcad.export.pdf
{
"msg": "PDF export successful. Use the link provided to view or download the file.",
"data": {
"download_link": "https://..."
}
}

If the export fails, for example because no pdfPages are defined, the response is:

Sample error response for cloudcad.export.pdf
{
"status": 1,
"data": "",
"msg": "PDF export failed."
}


See also#