Preparing Laser Cutting Files from SVGs

Here’s a trick I’ve been using to prepare files for laser cutting that have been exported to SVG.

SVG is just an XML file that contains a bunch of vectors and metadata. Here’s an example of one exported from OpenSCAD. Remember this, I didn’t.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="76mm" height="80mm" viewBox="-38 -40 76 80" xmlns="http://www.w3.org/2000/svg" version="1.1">
<title>OpenSCAD Model</title>
<path d="
M 37.5,-40 L -37.5,-40 L -37.5,40 L 37.5,40 z
M 34.3605,-35.4061 L 34.2222,-35.4243 L 34.0859,-35.4545 L 33.9528,-35.4965 L 33.8238,-35.5499 L 33.7,-35.6143
 L 33.5823,-35.6893 L 33.4715,-35.7743 L 33.3686,-35.8686 L 33.2743,-35.9715 L 33.1893,-36.0823 L 33.1143,-36.2
 L 33.0499,-36.3238 L 32.9965,-36.4528 L 32.9545,-36.5859 L 32.9243,-36.7222 L 32.9061,-36.8605 L 32.9,-37
 
 ...

 L -33.1893,37.9177 L -33.2743,38.0285 L -33.3686,38.1314 L -33.4715,38.2257 L -33.5823,38.3106 L -33.7,38.3856
 L -33.8238,38.4501 L -33.9528,38.5035 L -34.0859,38.5455 L -34.2222,38.5757 L -34.3605,38.5939 L -34.5,38.6
 z
" stroke="black" fill="lightgray" stroke-width="0.5"/>
</svg>

The laser cutter software I’m familiar with is Trotec JobControl for the Speedy line (it’s what we have at the Fat Cat Fab Lab). The files need to be prepped for the software with the correct line thickness and color for each process. When using a design program like adobe illustrator or inkscape that’s just part of the design process and isn’t an issue but if you’re designing in a CAD program you’ll need to edit the exported file to set this up. The export style is at least not readily configurable in FreeCAD, KiCAD, or OpenSCAD.

Since SVGs are straight XML files we can edit the file directly with a text editor. I remove the style line and replace it with the desired settings and we’re ready to cut!

...
" stroke="red" fill="none" stroke-width="0.01"/>
...

I’ll admit this post is entirely so I can remember to do it this way in 6 months.