SVG Export in QCAD is completely implemented in ECMAScript with one of the main classes being SvgExporterPG:
// include class SvgExporterPG:
include("scripts/Pro/ImportExport/SvgExporter/SvgExporterPG.js");
The export can be done through function 'exportFile':
var exporter = new SvgExporterPG(document, { "scale": "10:1"});
exporter.exportFile("example.svg");
Complete code:
//! [include]
// include class SvgExporterPG:
include("scripts/Pro/ImportExport/SvgExporter/SvgExporterPG.js");
//! [include]
//! [init]
// init application name:
qApp.applicationName = "MyApplication";
//! [document]
var storage = new RMemoryStorage();
var spatialIndex = new RSpatialIndexSimple();
var document = new RDocument(storage, spatialIndex);
document.setUnit(RS.Millimeter);
//! [document]
//! [operation]
// create an operation:
var operation = new RAddObjectsOperation();
// corner point of the triangle::
var p1 = new RVector(0, 0);
var p2 = new RVector(10, 0);
var p3 = new RVector(5, Math.sin(RMath.deg2rad(60))*10);
// add line entity to operation:
operation.addObject(new RLineEntity(document, new RLineData(p1, p2)));
operation.addObject(new RLineEntity(document, new RLineData(p2, p3)));
operation.addObject(new RLineEntity(document, new RLineData(p3, p1)));
// apply operation to document:
operation.apply(document);
//! [operation]
//! [export]
var exporter = new SvgExporterPG(document, { "scale": "10:1"});
exporter.exportFile("example.svg");
//! [export]