vpype for plotting

Wanted to give a shout-out for a great tool for working with SVG files and plotters: vpype. It’s a multifunctional tool for taking an SVG file you’re about ready to plot and then making it “better” for the plotter. Here’s an example of how I use it:

    read temp.svg
    crop 0.5in 0.5in 6in 4in
    write out.svg

That’s a pipeline that does the following (in order)

  • Read my input SVG
  • Crop the SVG to the given rectangle.
  • Merge lines if points are within 0.05mm of each other. This “cleans up” the SVG and makes for faster plots with fewer, more complex paths.
  • Re-order loop lines so that each loop starts at a random point. This breaks up artifacts from the pen at rest blotting ink into the paper.
  • Sort the lines to minimize pen up travel distance. Axidraw does this too but supposedly vpype works better.
  • Write out the output SVG

It’s a pretty powerful tool and what it can do is confusing at first. But the docs are good. The feature overview is the best list of commands it understands grouped by theme. Beyond that check out the cookbook and the CLI reference. There’s also a handful of plugins; the one that caught my attention is occult which will emulate the masking you get if you put a filled polygon on top of other stuff in an SVG file.

vpype works by default as a command line tool. It also has a Python API and the ability to write your own plugins in Python.

Under the hood what vpype is doing is interpreting the SVG to build up geometries in memory. It’s sort of like rasterizing things on a grid, although not quite. It then uses that model to allow it to combine lines, simplify geometry, etc. Along the way it squashes all curves into collections of little short lines. (The plotter would do this anyway, so no great loss).

Bonus image: it has a fun “squiggles” filter which makes the lines not straight.