Introduction: Week 5: G-Code Experiment (MAT238)

This week, I experimented with creating G-Code for a 3d printer not using a slicer to obtain effects with the 3d printer that aren't typically possible. I aimed to create a vase with a circle pattern on the surface from over-extrusion. I started with Mert Toka's cylinder G-Code generator in Grasshopper and adjusted it accordingly.

Supplies

  • Rhino (Grasshopper)
  • Ender 3

Step 1: Altering Cylinder's Shape

I wanted the radius of the cylinder to change with the height, so I adjusted the code for creating the cylinder to:

x = math.cos(ang) * Radius * (0.5*math.sin(i / 100) + 1)
y = math.sin(ang) * Radius * (0.5*math.sin(i / 100) + 1)

This gave the curved shape to my object.

Step 2: Creating the Circle Pattern

I used the Populate 3D node in Grasshopper to generate 20 randomly placed points around my object. I then used the following code to determine if any of the points on my object was within a 10mm radius of a randomly generated point.

for idx, point in enumerate(vertices):
    # Check if the point is close to any of the pattern points within the specified radius
    if any(rs.Distance(point, pattern_point) <= proximity_radius for pattern_point in pattern_points):
        closePoints.append(point)
        closeIndices.append(idx)

This gave me a list of points that were in the proximity if the random points (for visualization) and the indices of these points.

Step 3: Altering Extrusion Multiplier for Circle Pattern

From the list of points in the circle pattern from the previous step, I was able to adjust their extrusion multiplier in the code below:

for i, segment_length in enumerate(SegmentLen):
    # Check if the segment index is in the close indices list
    current_multiplier = ExtrusionMultiplierClose if i in CloseIndices else ExtrusionMultiplier

    # Calculate the extrusion amount for the segment
    extrusion = (4 * LayerHeight * segment_length * current_multiplier * NozzleWidth) / (math.pi * FilamentDiameter * FilamentDiameter)

    E.append(extrusion)

This allows me to change the relative extrusion multipliers for the desired effect.

Step 4: Creating G-Code

The G-Code lines are formed by concatenating all of the individual parameters, and the data from this panel can be copied and pasted into a text editor to create the G-Code file.

Step 5: Prints & Results

For these prints, I was mainly adjusting the extrusion multiplier for the pattern to get my desired result. I started with a multiplier of 1.2 for the pattern which seemed to print normally with no evidence of a pattern. I then bumped it up to 3 where I was able to get some semblance of a pattern, but it looks more like a defect than something intentional. I was hoping the pattern would bulge out, but that was not the case. I tried playing with under-extrusion and increasing the layer height, but the pattern still looked like a defect.

I hypothesize that with a larger nozzle, this effect would work better; however, working with the standard 0.4mm on the Ender 3, there was not much I could do. I decided to allow the 3x pattern multiplier print to finish, and at the end of the print, the printhead inexplicably crashed into the object. I'm not sure why this happened (my end G-Code sequence has the printhead moving out of the way), but this resembled how I felt about the result, so I see it as performance art