We have explored the anatomy of desktop 3D printer hardware of printed parts in a virtual objects that are the templates for what you produce with a 3D printer. I think it is important to briefly explore in more detail that last stage, that a 3D design must pass through on its way to becoming a physical object, the G-code job file. So what is G-code? G-code refers to a family of numerical control and C-code standards, that deliver instructions to computer-controlled manufacturing devices. While G-code is called a programming language, you might as well call it a machine instruction filed guideline, one that designers have computer-controlled tools can follow, extend, hack on, and ignore to their heart's content, whatever best suits their purposes or machine. This format has been so popular since it was first created in the 1950s that you'll see it popping up in many of the tools around you, popular enough that there are many any handy software tools out there in the world that can easily produce, simulate, and execute them. This is similar to the situation with the STL file format, many software and hardware projects have used it, and so more software and hardware has been created to use it. Many digital fabrication tools, such as CNCs, pen plotters, and 3D plotters, rely on these as job files followed by the tools onboard electronics. Specific Instructions are included for most of the activities that take place during the automated fabrication process. So why should I care about G-code? Here's the thing, you may find that you never ever have to pay attention to these files, except when you're looking to accomplish something unusual. The role of these files is to capture and describe in precise values the set of instructions a computer-controlled tool will follow, including triggering systems beyond the ones you'll notice. This is similar to PostScript files for two-dimensional printers, unless you are a computer scientist or a printer driver developer you probably won't look at post script files, but if you were to do so you would see every level of instruction needed to make sure that the print or display of the document is as intended. Similarly for G-code, while you will rarely, if ever, look at this file type, it is written for the machine to interpret after all. We are going to do so today, because this is an excellent way to understand all the activities that go into the operation of your printer. What does G-code look like? Good news for us, unlike PostScript files and other prepress or manufacturing instruction languages, the G-code variants used for desktop 3D printers are actually sort of human readable. For example, heat up toolhead zero to 220 degrees Celsius, lower the build platform 30 millimeters, turn off the active cooling fan, advance the extruder at this rate for this number of steps, move to the XYZ location at this speed. It makes for very uninspired reading, thousands and thousands of lines of simple instructions for executing even a tiny part. But on the other hand, there are handy resources for translating physical meshes into these lines of instructions, so this format has become the standard for 3D printers. So why not send the STLs and let the printers sort out the paths onboard? The short answer is that the mesh export file doesn't define enough of the decisions you need to make as an operator for how you intend to fabricate the object. Granted, a lot of the time you may be using a profile that will solve almost everything for you, but still you can't just go from the pure mesh to the physical object without matching up a lot of the different features of how you're going to print that file to the instructions. From a longer term perspective, the file sizes are smaller and easier to send as a series of packets over a serial connection or Wi-Fi than an image, file, or CAD design file. And for many of the simple variants, no compiling or pre-rendering is required for a control system to follow these instructions. 3D G-code viewer, as with the path viewer in Cura, there are other third-party tools out there that allow you to look at what is happening in G-code. Thanks to knowing what certain types of moves mean, this preview breaks out the extrusion moves from the travel moves. Comparing robot G-code to robot model in Cura, let's explore the thrilling anatomy of a simple G-code file. The most common G-code commands you need to know, here are my votes for some of the most common G-code commands that you might need to know. First, check out G0 rapid motion, used for travel, versus G1 coordinated movement, used for printing. Next, check out G90 absolute positioning versus G91 incremental positioning, absolute positioning is in terms of the origin point, or origin assignment, while relative mode, incremental mode, relative mode allows for movement to happen in terms of the place where the relative movement is declared. This is great for repeated patterns and simple utilities, where the exact absolute positioning is difficult to determine. G28, activating the homing process, versus G92, setting the current position as home. G28 activates a homing process and sends a machine to hit its end stops, while the G92 command is then handy for establishing the origin point on one or more axis. Usually used in combination with the homing activity, use of this command helps when end stops are mounted in odd but convenient places, making it possible to set the values for the position within the coordinate system to a set value, and so everything falls where it should. There are also an entire set of M-codes within G-code that generally involve recalling a value for the sensor, setting a value for an aspect of the machine, or causing the extruder to warm up to a target temperature. Let's take a look at M104, that's the command to start the heat of the extruders. This one allows you to run other commands at the same time, versus M109, which stops additional activities until the temperature's reached, tere also calls for the heated build plate or another extruder. Delivering G-code to your machine, much of desktop 3D printing up to now has been made possible, or at least a lot easier, thanks to G-code interpreter firmware that was created for Arduino based 3D printer electronics. Only a subset of G-code was implemented in that version, tools such as go to loops, patterns, and variables, leveraged to great effect in industrial CNCs and other computer-driven automation systems. Have been left out in the interest of a sequence of instructions that can be unspooled, a line at a time, at the moment of fabricating an object, without needing to read all the way to the end of the sequence. And while this is changing, as it costs drop for more sophisticated 32-bit 3D printer electronics and embedded systems that now play a greater role in managing, streaming, and altering bits of G-code during operation. For now, let's look at this as the simplest desktop 3D printers look at G-code. Let's watch some G-code happen. Now that you have seen what a G-code file looks like and how it functions, you have a few other opportunities that you might not have considered before. You can tune and tweak the start.G-code and end.G-code blocks, either in your 3D slicer or stored in firmware on your machine. What might you want to do? Change the location of various startup and print finished prescripted elements to better match shop policy for other machines, trigger automation, or mold it to your own habits. You can also create your own custom utility G-code files, like this leveling script created by educator Mark Peters, a fast way to check the platform calibration that suits how he prefers to test and adjust his machine. You can also assign your 3D printer to perform unexpected tasks, like this greeting card from Simon Oliver, and a few custom tweaks to allow your onboard electronics to control the discovery pace extruder from structured. If you are curious to learn more, check out the resources for this course, where you can find links to a few G-code utility projects, and listings for which G-codes and M-codes have been implemented by which machine vendors. And if you aren't that interested, chances are you might never need to crack open a G-code file ever again.