A 3D printer knows what to print because it receives a file of precise, line-by-line instructions telling it exactly where to move, how fast to go, how much material to push out, and what temperature to maintain. That instruction file, called G-code, is generated from your 3D design by a piece of software called a slicer. The entire process works like a chain: you create a digital shape, software translates that shape into thousands of thin horizontal layers, and each layer gets converted into movement commands the printer executes one at a time.
It Starts With a 3D Model
Every 3D print begins as a digital design, usually created in CAD (computer-aided design) software or downloaded from an online library. The model is a mathematical representation of a three-dimensional shape, defining every surface, curve, and edge. When you’re ready to print, you export that model as a file the printer ecosystem can work with.
The most common file format is STL, which breaks down your model’s surfaces into thousands of tiny triangles. The more triangles, the smoother and more detailed the shape. STL files are supported by virtually every slicer and printer combination, making them the universal standard. A newer format called 3MF goes further by storing color, material properties, textures, and even slicing settings inside a single compressed file. But regardless of format, the file itself isn’t what the printer reads. It’s just the shape data, a starting point that still needs to be translated into physical instructions.
One important detail: the model needs to be “watertight,” meaning no holes or gaps in the geometry. If the digital surface has missing patches, the printer won’t know what’s inside versus outside the object. Most slicers and third-party repair tools can detect and fix these problems automatically before you move to the next step.
The Slicer Turns a Shape Into Instructions
The slicer is where the real translation happens. This software takes your 3D model and does exactly what its name suggests: it slices the shape into a stack of thin, horizontal 2D layers. You choose the layer height (thinner layers mean finer detail but longer print times), and the slicer calculates how each layer should be drawn.
For every layer, the slicer determines the exact path the printer’s nozzle needs to follow. It figures out where to lay down material to create the outer walls, how to fill the interior (solid, honeycomb, or mostly hollow), where to add temporary support structures for overhanging sections, and how fast the nozzle should travel across each segment. It also handles practical details like when to speed up during simple fills and when to slow down for fine details.
The output of all this calculation is a G-code file. This is the only file the printer actually reads. It contains thousands of sequential commands, each one describing a single small action: move here, extrude this much plastic, set the temperature to this value, turn the cooling fan on. A typical print can contain hundreds of thousands of these individual instructions.
What G-code Actually Tells the Printer
G-code is surprisingly readable once you know a few basics. Each line is a short command with coordinates and values. A line like G1 X90 Y50 Z0.5 F3000 E1 tells the printer to move in a straight line to a position 90 mm along the X axis, 50 mm along the Y axis, and 0.5 mm up the Z axis, traveling at 3,000 mm per minute while pushing out 1 mm of filament. The G1 command specifically means “move while extruding.” A related command, G0, means “move without extruding,” which the printer uses for repositioning the nozzle between sections.
Temperature commands are baked into the G-code too. Before the printer starts laying down material, a command like M104 S210 tells the hot end to heat up to 210°C. Different materials need different temperatures, and the slicer writes these values into the file based on the material profile you selected. The G-code also controls bed temperature, fan speed, and retraction (pulling filament back slightly to prevent oozing when the nozzle travels between spots).
The printer doesn’t interpret or adapt these instructions creatively. It follows them in exact sequence, line by line, from start to finish. Every wall, every infill pattern, every layer change was pre-calculated by the slicer. The printer is simply executing a script.
How the Printer Tracks Its Own Position
To follow G-code instructions precisely, the printer needs to know where its nozzle is at all times. Most consumer printers use a Cartesian coordinate system, with separate stepper motors controlling movement along the X, Y, and Z axes independently. One motor slides the nozzle left and right, another moves the bed (or nozzle) forward and back, and a third raises or lowers the print head between layers.
Not all printers move the same way. CoreXY printers use a system of belts and pulleys where two motors work together to move the print head across a flat plane, while the bed moves vertically. Delta printers have three arms that coordinate simultaneously to position the nozzle anywhere in three-dimensional space. SCARA printers use a robotic arm with joints. Despite these mechanical differences, they all interpret the same G-code coordinates. The printer’s firmware handles the math to convert “move to X90 Y50” into the specific motor steps that particular design requires.
Sensors Keep the Print on Track
While G-code provides the plan, the printer also relies on real-time sensor feedback to execute it accurately. Temperature sensors called thermistors monitor the hot end and heated bed continuously, changing their electrical resistance as temperature shifts. The printer’s control board reads this resistance to calculate the current temperature and adjusts the heaters to stay on target. If the thermistor detects a dangerous deviation, like the temperature plummeting unexpectedly or spiking beyond safe limits, the firmware triggers a safety shutoff to prevent damage or fire.
Bed leveling is another area where sensors play a critical role. If the build surface isn’t perfectly flat or level relative to the nozzle’s path, the first layer won’t stick properly and the print will fail. Many printers include an automatic bed leveling probe near the nozzle tip that touches or scans several points across the build platform before printing starts. It measures the distance between the nozzle and the bed at each point, then calculates the actual tilt and shape of the surface. During printing, the firmware uses this map to make tiny Z-axis adjustments on the fly, keeping the nozzle at a consistent distance from the bed even if the surface is slightly warped.
Getting the File to the Printer
Once you have a G-code file, it needs to reach the printer. The simplest method is loading it onto an SD card or USB drive and plugging it directly into the machine. The printer reads the file from local storage and processes commands one at a time. This approach is reliable because it doesn’t depend on a computer staying connected throughout the print, which can take hours or even days.
Many users prefer networked printing instead. Software like OctoPrint runs on a small computer (often a Raspberry Pi) connected to the printer, providing a web interface you can access from any device on your network. You upload G-code through a browser, start and monitor prints remotely, and even watch progress through a camera feed. More advanced firmware like Klipper offloads much of the motion-planning computation to the connected computer, which can calculate smoother, faster tool paths than the printer’s built-in processor could handle alone. In either case, the G-code commands stream to the printer over a serial connection, and the printer executes them in real time.
Whether the file arrives on a memory card or over a network, the printer’s job remains the same: read each line, move accordingly, and build the object one thin layer at a time until the last command is reached.

