Write a post

Laser Cutting with Python

Published Nov 16, 2016Last updated Jan 18, 2017
Laser Cutting with Python

Wouldn't it be cool that apart from making apps, you can also produce physical things with your coding skills?

This basic tutorial will show you how you can use the Python Turtle library to create shapes ready for laser cutting! The concept is the same for any language, I'm using Python because lots of students use it in the UK.

Create a shape with the Turtle library

The Turtle library comes installed with Python, so you don't need to worry about installing it.

# import everything in the library
from turtle import *
# move forwards 100 pixels
# finish

Run your program, and you should see a line being drawn. The picture above is a necklace made by analyzing a sound file. After processing the .wav file, I needed to create a whole lot of circles. There are many primitive shapes you can use in the library — here're the docs.

Export the design

After you've done your design, the key part is exporting in a format suitable for the laser cutter. Fortunately, the canvas that the Turtle library uses can easily export to PostScript!

At the end of your program (but before the done()), add these lines:

# hide the little turtle icon so it doesn't get exported
# export the drawing as a postscript file

This will create a PostScript file in the current directory called circles.eps.

Cut it!

I use Corel Draw with my laser cutter, and it imports these files perfectly. I've also found SVGs to work well and there are lots of libraries for all languages you can use. An issue to watch out for is scaling, create a 100mm line somewhere and use it as a reference.

More info

I developed the waveform necklace as a way of making programming applied and fun. More information about processing the wave files and creating lots of circles is in the github repo here.

Have fun!

Discover and read more posts from matt venn
get started
Enjoy this post?

Leave a like and comment for matt

15 Essential Python Interview Questions
10 Neat Python Tricks Beginners Should Know
Cheat Sheet: Python For Data Science