lorenrogers / svg2gcode

Minimal SVG to GCode converter written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

svg2gcode

Build Status

Convert any SVG 1.1 path to gcode for a pen plotter, laser engraver, etc.

TODO

  • Support all path variants
  • Support group and path transforms
  • Biarc interpolation (G2/G3 instead of many G1)
  • Px, pc, in to mm
  • Configurable DPI for px/pc to mm
  • Sort paths by distance to reduce G0 distances
  • Configurable start/end sequence

Known bugs & whether fixed

  • Smooth curves should not use the control point when the previous curve is not of the same type (quadratic -> smooth cubic, cubic -> smooth quadratic)
  • Image coordinates mirrored in the y-axis because SVGs uses upper left corner as (0,0) while GCode uses lower left as (0,0)
  • Close path command connects back to (0.0, 0.0) instead of the last move
  • Ellipse paths are dubious -- large_arc, sweep may need to be inverted

Demonstration

Input

cargo run --release -- examples/Vanderbilt_Commodores_logo.svg

Vanderbilt Commodores Logo

Output, rendered at https://ncviewer.com

cat output.gcode

Vanderbilt Commodores Logo Gcode

FAQ / Interesting details

  • Can I convert a PDF to gcode? Yes! Follow this guide using Inkscape to convert a PDF to an SVG

  • Are shapes, fill patterns supported? All objects can be converted to paths in Inkscape with Object to Path for use with this program. Not sure how practical fill patterns would be -- if you have ideas, feel free to open as issue or a PR.

  • What about a generic PPD driver for using a plotter as a printer? I thought about doing something like this where you package ghostscript + inkscape + svg2gcode but since plotter dimensions and capabilities vary, this is an exercise left to the reader for now.

About

Minimal SVG to GCode converter written in Rust

License:MIT License


Languages

Language:Rust 100.0%