What are STL files and G-Code in 3D Printing?

What are STL files and G-Code, and why are they used in 3D Printing?

3D Printing is a phenomenally exciting Space-Age technology. However, your plastic masterpiece won't be auto-magically conjured by a simple Star Trek-like voice command. This is because there are currently a few steps in the process. From the initial design to its final clean up, and all the rewarding - albeit sometimes frustrating - stages in-between.

Firstly, converting the 3D model into a STL file is one of the most important steps in a 3D print.

What are STL files?

STL is a file format commonly used for 3D printing and computer-aided design (CAD). The name STL is an acronym that stands for stereolithography - a popular 3D printing technology.

For those who go to Pub Quizzes, they are also known as Standard Triangle Language or Standard Tessellation Language. A guaranteed 10 pointer - you're welcome.

Each file is made up of a series of linked triangles that describe the surface geometry of a 3D model or object. The more complex the design, the more triangles used, and the higher the resolution. 

You can recognize an STL image by its .stl file extension and by its lack of colour and texture.

Once the STL file is created it can be loaded into cutting software known as slicers. These include brands such as Cura, Simplify3D or Repetier (to name only three of dozens and dozens). Your 3D Printer will more than likely be shipped with a 3D slicer, which will usually be perfectly sufficient.

Slicers convert the STL design file into another file that can be read by a 3D printer. This file contains something called G-Code, a programming language that tells machines how to manufacture the final part. 

What is G-Code and how important is it in the manufacturing process?

G stands for geometry, and it’s the alphanumeric format the system uses to tell the parts what to do. Put simply, it indicates where to start, how to move and when to stop.

G-code is also known as RS-274, which is a spectacularly cryptic moniker rarely used outside of Boffin-circles. 

No matter what it is called, it is the most commonly used programming language for Computer Numerical Control (CNC), 3D Printing and Computer-Aided Design and Manufacturing (CAD/CAM).

Amazingly, the first numerical computer control language was developed by MIT back in the Happy Days of the late 1950s. This led to the earliest version of G-Code, which was standardised by the Electronic Industries Alliance in the early 1960s … groovy! 

Today, G-code, and similar languages, ensure precise and infinitely reproducible manufacturing of all kinds of equipment and consumer goods.

So, how does G-Code work?

G-code instructs the computer-controlled manufacturing equipment to move the head through 3D manoeuvres at differing speeds to create the desired result.

The G-Code consists of G and M commands, each of which have an assigned motion or action. The combination of these commands will allow the 3D printer to understand which pattern to follow in order to create the final product. 

What is the difference between G-Code and M-Code?

A G code controls the movements of a machine, dictating how and where a machine should move to fabricate a part.

An M code controls miscellaneous machine functions, including starting and stopping specific actions or programs.

These two codes work together to manufacture parts and components, making them essential in the manufacturing and industrial sectors.

What is a G-Code made up of?

G-code is written in a surprisingly straightforward and logical way.

A “G” is followed by a number, which is a command to change geometry.

Examples of G-code:

  • G00: Move quickly to a specific coordinate position
  • G01: Linear feed move
  • G02/G03: Clockwise/counterclockwise feed move

These codes are followed by a geometric location. The geometry is conveyed with coordinates on axes - an “X, Y and Z” coordinate on a plane. A 3D printer’s lateral movement is usually assigned to the X- and Y-axis, while the Z-axis is for vertical motion.

For instance, “G00G58X-120.Y-5.” “G00” means a rapid move. “G58” is the work coordinates, changing geometry relative to work offsets, like the part origin. “X-120.” means to go to “-120mm” on the X axis, and  “Y-5.” means to go to “-5mm” on the Y axis.

The list of G-Codes and M-Codes is extensive. In fact, there are more than 1,000 different commands that can tell the 3D printer what to do at any given moment. And, because there could be thousands of movements involved to produce a 3D print, the G-Code may be hundreds of pages long.

I would be understating it somewhat if I pointed out writing all this code manually would take some time indeed! 

But don’t fear, you will probably never need to know any of them, because the language is automatically generated by the slicer prior to the manufacturing process.

However, it is always good to look under the hood to appreciate the magnificent complexity behind something as simple as a 3D-printed, novelty-shaped phone holder.

For a great range of 3D Printers, 3D filaments and printer parts, check out Tools for School's range.

X As of the 1st of December we have updated our website!

If you haven’t reset your password since then, please click here to reset your password. Reset Password
chat