News

How to draw a rectangle in Gcode

So you’ve played with the Makelangelo‘s generated Gcode and now you want to experiment on your own. Cool! Here’s a simple rectangle to get you started.

Now let’s give some values to these parameters:

A20
B40
C10
D30

My method is to lift the pen, drive to a corner, put the pen down, and then trace the rectangle. That means going to five points because we have to come back to the start.

G0 Z90; # pen up
G0 X-10 Y20;  # p1 
G0 Z40; # pen down 
G0 X30 Y20;  # p2
G0 X30 Y-40;  # p3 
G0 X-10 Y-40;  # p4 
G0 X-10 Y20;  # p1 again
G0 Z90; # pen up

And voila! I’ve deliberately done this with the origin away from the center so the numbers are more obvious. I hope you see that in a cartesian system the origin could be anywhere. For example, if it were below and to the left of P4 all the X and Y values would be positive.