[computational Fabrication] Generating Gcode in Grasshopper and Making Eclipse Coasters

Introduction: [computational Fabrication] Generating Gcode in Grasshopper and Making Eclipse Coasters

The goal of this project is to explore a higher level of abstraction in 3d printing by experimenting with generating gcode* in Grasshopper. Yes, it is open-ended and sounds challenging. Thankfully my instructor (see below) has broken this down into bite-sized components.

This is the fourth project for a course I’m taking this quarter (Spring 2020) on computational fabrication taught by Prof. Jennifer Jacobs at the Media, Arts & Technology program at the University of California Santa Barbara. The idea behind the course is that digital fabrication can be combined with computational design to create complex and functional physical forms.

Also I’m always iterating on my process! My lesson from last week was to print, print, print! The whole process seems very artifact dependent and I’m going to try to work as incrementally as possible.

Tools I used for this work include

  • Rhinoceros (Rhino), a commercial NURBS-based computer-aided design (CAD) tool
  • Grasshopper, a visual programming language based on a data flow paradigm that lets you parametrize the geometry you create in Rhino
  • Ultimaker CURA, an open source 3D printer slicing application
  • Creality Ender 3D Pro, a commercially available 3D printer supplied by UCSB

*gcode is the specification language used to control automated machine tools. There are many variants. The Creality Ender Pro 3d uses the Marlin specification which is an open source firmware project geared towards 3d printers. There are roughly 150 commands and you can check out the whole thing here: https://marlinfw.org/meta/gcode/

Step 1: STEP ONE [Getting Started]

This project is inspired by 3d Printed Fabric: Techniques for Design and 3d Weaving Programmable Textiles by Haruki Takahashi and Jeeun Kim that was shared at UIST ‘19 (The ACM User Interface Software and Technology symposium) [1].

They create a 3d textile (a form that is flexible) by creating loops of filaments that don’t adhere to one another but are instead wrapped around support structures. The first thing I did was read (ok skim) their paper. The related work section was really interesting -- there are many examples of using modified gcode to create unexpected outputs that use filament in novel ways -- and I noticed some details that are important to their process.

To elaborate, the fabrics consist of a base structure, end supports and pillars that rest on the base and then strands of filament woven attached to the end supports and woven through the pillars. This creates flexibility in the direction of the layout of the pillars. They fine tune parameters like speed and infill density of the base and pillars to achieve the desired effect and maintain the integrity of the resulting print.

Our instructor Jennifer created a simplified version of the authors code in Grasshopper that she shared with us. She also shared an example of a simple slicer executed in Grasshopper. The one based on the paper felt a bit overwhelming so I’m starting with the latter.

Her slicer takes a brep (boundary representation = common object representation) and extracts the bounding box and a mesh from it. She generates a plane with a set of points and replicates it using a layer density parameter along the z-axis and calculates the mesh intersection. This returns a series of curves that can be decomposed into points that can be sent to the printer.

The command G1 is used for linear moves that require extrusion. It takes in the parameters X, Y, Z, F, and E. The last one indicates the length of filament to extrude and is calculated using the nozzle width and filament thickness. The penultimate parameter is the max movement rate between the start and end point.

I included a picture of a simple object I’m going to try and print using the slicer and partial image of the corresponding gcode. Loading the gcode in Cura and showing the extruder travels provides an indicator of the output. I printed it and another test print of an object where I doubled the feedrate (F).

[1] https://dl.acm.org/doi/10.1145/3332165.3347896

Step 2: STEP TWO [Getting Familiar With Gcode]

My idea for a slicer is based on my fabrication experience in my last project. I created conical structures. I expected the fabrication to rely on adhesion to the outer rim of the previous layer but what happened was that the gcode generated an unsupported overhang. While this was well disguised in the final output, the interior of the object was messy and delicate as a result.

So my idea is to generate gcode that vertically appears to zig zag and only uses concentric circles to generate geometry. However I wanted a more stylized and experimental outcome. So I wanted to introduce a generative element.

The idea is to use disks that are filled in probabilistically.

Ok, so the first try (printing a ring) didn’t really work out. It looks like way too much filament is being extruded and the points are too close together. Upon inspection of the actual print, the nozzle wasn’t being to a greater radius so excess filament was being printed continually. The one layer example shows a stove top like structure. It’s flexible but peels off like a filament and doesn’t adhere to itself.

The next step is to decrease the distance between the rings and create height. My first test revealed that I wasn’t extracting filament to prep for printing. I also hadn’t increased the layer height even though I had a G0 command with z movement stipulated. Going to try this again…. 8 test prints later it finally works! I’m not sure why I’m taxing my printer with printing at a resolution of .1mm but you can see the results of a 10 layer stack with 3 concentric rings. I printed another one with a layer height of 0.5mm.

I ended up visualizing the path of the extruder to better help gauge the result in Rhino by creating a line through all of the points being printed and also outputting the points themselves. This was very helpful.

Another “hack” was to print a layer at z = 0. This created a surface that adhered well to the bed even though its probably not a best practice.

Step 3: STEP THREE [Experimenting]

Now that I can print concentric rings (very exciting), I can experiment a bit. I want to try to really ramp up the speed of the print for the outer rings. I also want to experiment with the location of the knot (the connection between rings) and have that vary as discussed above. The idea was to create a shape that has a bleed like the outline of an eclipse. I think I can create an interesting set of coasters once I fine tune the output.

I think it will take some more experimentation with adjusting the parameters to get the result I had in mind. I have a fever this week and am going to wrap up here.

Perhaps I could finish the slicer later which would work by intersecting a mesh and only printing points in rings that are inside the mesh. Another extension could be to support undulating forms by printing only connected rings moving repeatedly up and down the shape. This could be a possible course project.

In the end it was fun to test the capabilities of the printer and get more comfortable and experiment with extraction / retraction, feed rate, and speed.

Accompanying code and STL files can be accessed in my git repo here:

Be the First to Share


    • Teach With Tinkercad Contest

      Teach With Tinkercad Contest
    • Cheese Challenge

      Cheese Challenge
    • Fried Food Challenge

      Fried Food Challenge



    Question 2 years ago

    Your eclipse looks great! Do you remember what layer height did you use for the first image in step 3? The filament looks quite thick (or is it just perspective?)


    Answer 2 years ago

    Hi Mert! Thanks and I'm sorry I missed your question. I used a layer height of 0.5mm!


    2 years ago

    hey sonia, great work and thanks for sharing your process! You took a very structured way to explore the possibilities of the 3D printer, and you seem to have gained a lot of knowledge out of it.

    Reading your steps, I find interesting that I did some similar realizations during my own gcode exploration, so maybe there is something didactical to get out of it. Some kind of guiding principles.. I also felt that some of these realizations could be my course project, like if the analytical investigation of the 3d printer could enable interesting things to happen. It felt like scientific inquiries.


    2 years ago

    I like how natural one of your prototypes look! It looks like bamboo weaving! Thanks for sharing your experiences!