Categories
Computational Design Digital Fabrication

G-Code Exporter From Grasshopper – Clay Printing

I wrote this simple G-code exporter from Grasshopper. I have tested the code with Wasp 2040 and Wasp 3mt. They both worked flawlessly.

You can input your points into the designated parameters, and the code will be generated. Please note that if the points have multiple branches, a “stop extrusion” command will be added at the end of each branch (G92). This is useful when transitioning from one layer to another or when printing a non-monolithic shape. If you prefer a continuous flow without any interruptions, simply flatten all your points.

The overall logic is very simple and can be understood from the Grasshopper file. Basically, it generates points where you want the nozzle to go and uses the X/Y/Z values of those points to create a linear movement command (G0/G1). To calculate how much material needs to be extruded between each pair of points, you need to find the distance between those two positions. It is conventional to add a multiplying number to that distance, as seen in the code (1. 3). In my experience, a constant flow rate of 2000 mm/s worked fine. The rest of the fine-tuning can be done using the printer firmware mid-print, based on the properties of the material.

There is also a Python component that saves your G-code as a file with a . gcode extension for convenience. If you wish to use it, remember to specify a directory first. (Right-click on the file path parameter and select ‘Set Directory’.).

I also realized that having to focus on the geometry in Grasshopper can prevent one from foreseeing possible errors in the code. Therefore, creating another layer of checking at the end involves using Python to convert the G-code back to geometry (points), allowing you to see what is actually happening.

  • I was only in charge of the machining and programming parts. Credit for the rest goes to other instructors at UofC and the students in the corresponding course (Arch 680 L03, Special Topics in Architecture (Winter 2024) Lili Yas Tayefi).

A very useful GCode cheat sheet is the one that is provided here.

https://reprap.org/wiki/G-code

Additionally, here are some other links you might find useful:

CAUTION: Please always triple-check every line of code and ensure you understand its function before running it. For example, in my case, I disable the motors at the end with an M84 command. In your case, your extruder may become loose and fall onto your printed piece. This code serves as an educational base and comes with no warranty of any kind.
The author cannot be held responsible. That aside, use it as you wish, no credit is needed for me;)

Leave a Reply

Your email address will not be published. Required fields are marked *