Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
layerOptions: {
engrave: {
fill: 'red',
stroke: 'red'
}
}
})
const folder = path.join(__dirname, 'output')
mkdirp.sync(`${folder}/svg`)
mkdirp.sync(`${folder}/html`)
mkdirp.sync(`${folder}/dxf`)
mkdirp.sync(`${folder}/json`)
fs.writeFileSync(`${folder}/svg/absolem_${title}.svg`, svg)
fs.writeFileSync(`${folder}/html/absolem_${title}.html`, html_prefix(title) + svg + html_suffix)
fs.writeFileSync(`${folder}/dxf/absolem_${title}.dxf`, m.exporter.toDXF(assembly))
fs.writeFileSync(`${folder}/json/absolem_${title}.json`, JSON.stringify(assembly, null, ' '))
console.log(`Assembly '${title}' dumped...`)
}
function toDXF(model: MakerJs.IModel, options: MakerJs.exporter.IDXFRenderOptions) {
if (!options.units) {
options.units = model.units || makerjs.unitType.Millimeter;
}
return makerjs.exporter.toDXF(model, options);
}
return toDXF;
//TODO: watermark
//TODO: title, author, grid from options
var pdfOptions: PDFKit.PDFDocumentOptions = {
compress: false,
info: {
Producer: 'MakerJs',
Author: 'MakerJs'
}
};
var doc: PDFKit.PDFDocument = new PDFDocument(pdfOptions);
var reader = new StringReader(complete);
var stream = doc.pipe(reader);
//TODO: break up model across pages
makerjs.exporter.toPDF(doc, model, exportOptions);
doc.end();
}
return toPdf;
return makerjs.exporter.toJson;
case f.Dxf:
function toDXF(model: MakerJs.IModel, options: MakerJs.exporter.IDXFRenderOptions) {
if (!options.units) {
options.units = model.units || makerjs.unitType.Millimeter;
}
return makerjs.exporter.toDXF(model, options);
}
return toDXF;
case f.Svg:
return makerjs.exporter.toSVG;
case f.SvgPathData:
return makerjs.exporter.toSVGPathData;
case f.OpenJsCad:
return makerjs.exporter.toJscadScript;
case f.Stl:
function toStl(model: MakerJs.IModel, options: MakerJs.exporter.IJscadCsgOptions) {
if (!deps[MakerJsPlaygroundExport.ExportFormat.Stl]) {
importScripts(
'../../../external/jscad/csg.js',
'../../../external/jscad/stl-serializer.js'
);
deps[MakerJsPlaygroundExport.ExportFormat.Stl] = true;
}
//make sure size is in mm for STL
function writeHeading(level, heading) {
var h = new makerjs.exporter.XmlTag('h' + level);
h.innerTextEscaped = true;
h.innerText = heading;
stream.write(h.toString());
stream.write('\n\n');
}
function writeThumbnail(key, kit, baseUrl) {
);
deps[MakerJsPlaygroundExport.ExportFormat.Stl] = true;
}
//make sure size is in mm for STL
model = makerjs.model.convertUnits(model, makerjs.unitType.Millimeter);
const { CAG }: { CAG: typeof jscad.CAG } = require('@jscad/csg');
const stlSerializer: jscad.StlSerializer = require('@jscad/stl-serializer');
options.statusCallback = function (status) {
result.percentComplete = status.progress;
postMessage(result);
}
return makerjs.exporter.toJscadSTL(CAG, stlSerializer, model, options);
}
return toStl;
function toDXF(model, options) {
if (!options.units) {
options.units = model.units || makerjs.unitType.Millimeter;
}
return makerjs.exporter.toDXF(model, options);
}
return toDXF;
function toStl(model, options) {
if (!deps[MakerJsPlaygroundExport.ExportFormat.Stl]) {
importScripts('../../../external/jscad/csg.js', '../../../external/jscad/stl-serializer.js');
deps[MakerJsPlaygroundExport.ExportFormat.Stl] = true;
}
//make sure size is in mm for STL
model = makerjs.model.convertUnits(model, makerjs.unitType.Millimeter);
var CAG = require('@jscad/csg').CAG;
var stlSerializer = require('@jscad/stl-serializer');
options.statusCallback = function (status) {
result.percentComplete = status.progress;
postMessage(result);
};
return makerjs.exporter.toJscadSTL(CAG, stlSerializer, model, options);
}
return toStl;