How to use the makerjs.exporter function in makerjs

To help you get started, weā€™ve selected a few makerjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mrzealot / absolem / plans / absolem.js View on Github external
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...`)
}
github microsoft / maker.js / packages / playground / src / worker / export-worker.ts View on Github external
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;
github microsoft / maker.js / packages / playground / src / worker / export-worker.ts View on Github external
//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;
github microsoft / maker.js / packages / playground / src / worker / export-worker.ts View on Github external
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
github microsoft / maker.js / docs / demos / demoify.js View on Github external
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) {
github microsoft / maker.js / packages / playground / src / worker / export-worker.ts View on Github external
);
                    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;
github microsoft / maker.js / docs / playground / js / worker / export-worker.js View on Github external
function toDXF(model, options) {
                if (!options.units) {
                    options.units = model.units || makerjs.unitType.Millimeter;
                }
                return makerjs.exporter.toDXF(model, options);
            }
            return toDXF;
github microsoft / maker.js / docs / playground / js / worker / export-worker.js View on Github external
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;

makerjs

Maker.js, a Microsoft Garage project, is a JavaScript library for creating and sharing modular line drawings for CNC and laser cutters.

Apache-2.0
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis