svg-to-gcode
v1.4.1
Published
Convert SVG files to G-code for plotter
Downloads
334
Maintainers
Readme
Svg-To-GCode Converter
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,
seekRate : 2000,
zValue: -15,
tolerance: 0.1,
minimumArea: 2.5,
pathPlanning: 'minimumTravel',
quadrant: 1,
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);
})