---
title: Tutorial 32 Non-planar Toolpaths
description: Printing on curved surfaces.
---
Tutorial 32 Non-planar Toolpaths
1. Lesson Header
- Lesson Number: 32
- Level: Advanced
- Title: Non-planar Toolpaths
- Estimated Duration: 50 Minutes
- Prerequisites: Lesson 22 (Non-planar Intro), Lesson 27 (Math Generation)
- What You Will Build: A "Surface Ironing" Script for a Dome.
2. Concept Introduction
The Z-Clearance Problem.
In Lesson 22, we made a simple wave.
Now we want to print on top of a complex object (e.g., a dome or a shoe sole).
The challenge: Collision.
The nozzle is a cone. The heater block is a rectangle.
If the surface slope > Nozzle Angle (usually ~45-60 degrees), the shoulder of the nozzle hits the print.
3. Machine State Explanation
Tool Geometry.
We need to model our tool.
- Nozzle Tip: Point (0,0,0).
- Nozzle Shoulder: Circle at Z=1mm, Radius=1mm (Example).
- Heater Block: Rectangle at Z=3mm, Width=20mm.
Algorithm:
For every point (x,y,z) on our target surface:
Check if (x,y,z) + Tool_Shape intersects with Existing_Print.
4. Command Breakdown
- G1 X... Y... Z...: Simultaneous 3-axis movement.
- Mesh/Surface: We need a mathematical definition of the surface (e.g.,
Z = sqrt(R^2 - X^2 - Y^2)for a sphere).
5. Minimal Working Example
The Dome Finish.
1. Print a standard stepped dome (Layer height 0.2mm).
2. Switch to Non-planar Mode.
3. Run the nozzle over the steps in a spiral to smooth them out ("Ironing").
6. Visual Representation
Interactive preview is available in the interactive reader.
7. Build Exercise
Task: Write a Python script to generate a Non-planar Ironing path for a Sphere (R=20mm).
Path: A spiral starting at Z=20 (Top) and winding down to Z=10.
Constraint: The nozzle angle is 45 degrees.
So we can only iron down to where the surface tangent is 45 degrees.Slope = dz/dr = -r/sqrt(R^2 - r^2).
Find r where slope = 1.
8. Deep Insight Section
Slicing Software.
Standard slicers (Cura, PrusaSlicer) are starting to support "Non-planar Layers" (experimental).
But doing it manually teaches you the limits.
The "Fan" Trick:
You can print steeper angles if you have a pointy nozzle (Airbrush nozzle adapter).
9. Common Failure Modes
- Gouging: If your Z calculation is slightly too low, the nozzle digs into the plastic.
- Air Printing: If Z is too high, you are just extruding spaghetti in the air above the surface.
10. Real-World Application
Shoe Soles.
Printing tread patterns onto a curved shoe sole.
The sole is molded (or printed flat then bent), and the printer adds texture after.
This requires a 5-axis machine or very careful 3-axis non-planar paths.
11. Final Clean Version
The Ironing Script:
import math
filename = "dome_iron.gcode"
R = 20
start_angle = 0 # Top (0 degrees from vertical? No, let's say 0 is pole)
end_angle = 45 # Stop at 45 degrees
steps = 1000
with open(filename, "w") as f:
f.write("G21\nG90\nG28\n")
# Assume dome is already printed and centered at 100,100
cx, cy = 100, 100
# Lift Z to safe height
f.write(f"G0 Z{R+5}\n")
f.write(f"G0 X{cx} Y{cy}\n") # Go to center
# Spiral Out
for i in range(steps):
# Current angle from pole (0 to 45 degrees)
phi = (i / steps) * math.radians(end_angle)
# Spiral angle (theta)
theta = i * 0.5 # Winding speed
# Spherical coordinates
r = R * math.sin(phi)
z = R * math.cos(phi)
x = cx + r * math.cos(theta)
y = cy + r * math.sin(theta)
# Move
# Note: We extrude very little, just to smooth/iron
f.write(f"G1 X{x:.3f} Y{y:.3f} Z{z:.3f} E... F1000\n")
f.write("G28 X0 Y0\n")
12. Stretch Challenge
Challenge: Write a script that detects collision.
Given a surface function Z(x,y), determine the maximum steepness your specific nozzle can handle.
Print a "Test Slope" object that increases angle until the nozzle hits.
Measure the angle where the finish gets ruined.