---
title: Tutorial 6 Layers
description: Creating 3D objects by stacking 2D movements.
---
Tutorial 6 Layers
1. Lesson Header
- Lesson Number: 6
- Level: Intermediate
- Title: Layers
- Estimated Duration: 25 Minutes
- Prerequisites: Lesson 3 (The G1 Command)
- What You Will Build: A 5mm tall hollow cube.
2. Concept Introduction
3D Printing is just 2D Printing, Repeated.
A 3D printer is a dumb robot that draws a picture on a flat surface. Then, the bed lowers (or the nozzle raises) by a tiny amount—usually 0.2mm—and it draws the exact same picture again.
If you stack 100 sheets of paper, you get a book. If you stack 100 layers of plastic, you get a solid object.
The magic number is Layer Height.
- Standard: 0.2mm
- Fine: 0.1mm
- Draft: 0.3mm (for 0.4mm nozzle)
3. Machine State Explanation
Z-Axis Precision
The Z-axis is the most precise axis on your machine. It moves very slowly but with immense torque.
- Z-Hop: Lifting the nozzle to move without scratching the print.
- Layer Change: The specific moment Z increases.
4. Command Breakdown
The Z Move (G1 Z...)
Just like X and Y, Z is a coordinate.
- Syntax: G1 Z0.4
- Meaning: Move the nozzle to height 0.4mm above the bed.
Comments as Structure (; Layer 1)
Since G-code files can be millions of lines long, slicers use comments to mark where a new layer begins.
- Syntax: ;LAYER:1
- Use: Helps humans (and some plugins) navigate the file.
5. Minimal Working Example
Let's print a square that is 2 layers tall.
; Layer 1 (Z=0.2)
G1 Z0.2
G1 X10 Y10 E1
G1 X20 Y10 E1
G1 X20 Y20 E1
G1 X10 Y20 E1
G1 X10 Y10 E1 ; Close Loop
; Layer 2 (Z=0.4)
G1 Z0.4
G1 X10 Y10 E1
G1 X20 Y10 E1
G1 X20 Y20 E1
G1 X10 Y20 E1
G1 X10 Y10 E1 ; Close Loop
Notice the code block for the square is identical. Only the Z height changed.
6. Visual Representation
Interactive preview is available in the interactive reader.
7. Build Exercise
Task: Create a 10mm x 10mm square tower, 3 layers high.
- Layer Height: 0.3mm.
- Start Position: X50 Y50.
...
Solution:
G21
G90
M83
G28
; Layer 1
G1 Z0.3
G1 X50 Y50 ; Move to Start
G1 X60 Y50 E1 ; Right
G1 X60 Y60 E1 ; Back
G1 X50 Y60 E1 ; Left
G1 X50 Y50 E1 ; Close
; Layer 2
G1 Z0.6 ; Move Up 0.3mm
G1 X60 Y50 E1
G1 X60 Y60 E1
G1 X50 Y60 E1
G1 X50 Y50 E1
; Layer 3
G1 Z0.9 ; Move Up 0.3mm
G1 X60 Y50 E1
G1 X60 Y60 E1
G1 X50 Y60 E1
G1 X50 Y50 E1
8. Deep Insight Section
Automation (Why we use Slicers)
Writing 3 layers by hand is annoying. Writing 1000 layers (a 20cm tall object) is impossible.
This is where Variables and Loops come in.
Standard G-code doesn't support loops (it's just a list of commands).
However, Macro G-code (used in Klipper/Duet/Marlin 2.0) or generating scripts (Python/JS) allows us to say:FOR i in range(0, 100): PrintSquare(Z=i*0.2)
We will cover parametric G-code in Lesson 20. For now, copy-paste is your friend.
9. Common Failure Modes
- Z-Fighting / Squish: If you forget to raise Z (e.g., Layer 2 is at Z=0.2 just like Layer 1), the nozzle will plow through the plastic it just laid down. It looks messy and ruins the surface.
- Too High: If you raise Z too much (e.g., Z=1.0 for Layer 2), you are printing in mid-air. The plastic will turn into spaghetti.
10. Real-World Application
Vase Mode (Spiralize Outer Contour)
"Vase Mode" is a special slicer setting that turns a 3D object into a single continuous line.
Instead of:
1. Draw Layer.
2. Stop.
3. Move Z up.
4. Draw Layer.
It does:
1. Draw while slowly moving Z up continuously.G1 X10 Y10 Z0.2 -> G1 X20 Y10 Z0.25 -> ...
It's a true 3D spiral!
11. Final Clean Version
Save this as lesson6.gcode.
; Lesson 6 - The 3-Layer Tower
; Setup
G21
G90
M83
G28
; Heat Nozzle (Manual or M104 S200)
; --- Layer 1 ---
G1 Z0.3 F3000 ; Move to height
G1 X100 Y100 ; Move to Start
G1 F1500 ; Print Speed
G1 X120 Y100 E2 ; Leg 1
G1 X120 Y120 E2 ; Leg 2
G1 X100 Y120 E2 ; Leg 3
G1 X100 Y100 E2 ; Leg 4
; --- Layer 2 ---
G1 Z0.6 ; Move Up
G1 X120 Y100 E2 ; Leg 1
G1 X120 Y120 E2 ; Leg 2
G1 X100 Y120 E2 ; Leg 3
G1 X100 Y100 E2 ; Leg 4
; --- Layer 3 ---
G1 Z0.9 ; Move Up
G1 X120 Y100 E2 ; Leg 1
G1 X120 Y120 E2 ; Leg 2
G1 X100 Y120 E2 ; Leg 3
G1 X100 Y100 E2 ; Leg 4
; Finish
G0 Z10
G0 X0 Y200
12. Stretch Challenge
Challenge: Create a "Pyramid" effect.
- Layer 1: 30x30 square.
- Layer 2: 20x20 square (centered on the first).
- Layer 3: 10x10 square (centered).
Hint: Calculate the center point first (e.g., X100 Y100).
Answer Key:
; Center is 100,100
; L1 (30 wide): 85 to 115
; L2 (20 wide): 90 to 110
; L3 (10 wide): 95 to 105