Détail du package

svg-to-gcode

MidlajN738ISC1.4.5

Convert SVG files to G-code for plotter

Svg, svg2gcode, gcode, plotter

readme

Svg-To-GCode Converter

npm version

svg-to-gcode is an npm package that helps in SVG file inputs into G-Code text for a plotter. It's a friendly modification of the opensource respository "exportSVGtoGCODE" by o0morgan0o, originally a Node CLI tool. You can easily incorporate this package into your frontend application.

Installation

Install the package using npm:

npm install svg-to-gcode

Usage


import { Converter } from 'svg-to-gcode'

// Configuration for the plotter gcode ( the values are in mm)
const settings = {
    zOffset : 3, 
    feedRate : 3000, // mm/min
    seekRate : 2000, // mm/min
    zValue: -15,
    tolerance: 0.4,
    minimumArea: 2.5,
    pathPlanning: 'minimumTravel',
    quadrant: 1,
    xOffset: 10,
    yOffset: 10,
    bedSize: {
        width: 420,
        height: 297
    }
}
// For using the default configuration , skip the settings
const converter = new Converter(settings)

// You can download the generated gCode using this code
converter.convert(data).then((gcode) => {
    const file = new Blob([gcode], { type: 'text/plain' });
    const link = document.createElement('a');
    link.href = URL.createObjectURL(file);
    link.download = 'out.gcode';
    link.click();
    URL.revokeObjectURL(link.href);
})