What comes to mind when you hear "G-code"?
Probably most people think of the buzzing motor sounds from a 3D printer, or the sparks flying when a CNC machine cuts through metal. But did you know that these seemingly cold coordinate commands actually hide quite a few "little secrets"—especially those movement paths encoded into the shapes of text? The skill I'm going to talk about today is specifically for this: "digging" text content out of G-code files.
Why do we need this skill?
Let's start with a question: if a 3D printer is going to print a nameplate that says "HELLO," will its G-code file contain the letters "HELLO"? The answer is—no! It only contains a bunch of X, Y, Z coordinates and G0/G1 commands. The shape of the letters is entirely determined by the connecting paths between those coordinate points, just like drawing letters with a pen—except this pen is digitally controlled. So if you want to figure out what text a given G-code file will actually print, simply reading the file contents won't cut it; you have to analyze its geometric paths.
This skill is designed to solve exactly that pain point. Its core idea is: the G-code itself is the content. The text is hidden within the coordinate sequences; what you need is a method to visualize them into shapes, and then recognize them. The use cases are quite broad—covering processes like 3D printing, CNC engraving, and laser cutting. Anywhere text or symbols are machined, this can come in handy.
What exactly can it do?
- Identify printed/engraved content: Got a G-code file and don't know what text it will produce? Analyze the coordinates, plot them, and it becomes clear at a glance.
- Reverse engineering: Someone gives you an engraving file, and you want to know what's carved on it, or you want to convert embossed text back into vectors—this skill is perfect for that.
- Quality verification: Confirm whether the path the equipment actually executes matches the design, checking for missing letters or misalignments.
My practical experience
When I first came across this skill, I was a bit confused. I thought, "Isn't this overkill? Why not just look at the file name?" But after using it once, I realized—file names can be a trap! There was a file called "text.gcode," and I naturally assumed it printed "text." But after analyzing it, I found out it actually printed "LOVE." I almost made a fool of myself. So the skill documentation specifically emphasizes: never treat the file name as the conclusion; the geometric data is what matters.
The actual steps aren't difficult. Step one: look through the file for object tags like M486 or comments—those can help you locate the section containing the text. Step two: extract the X and Y coordinates from the G0/G1 commands in that section. Step three: use Python's matplotlib to plot the graph, and the path appears, with the letter shapes becoming obvious at a glance. If you don't have a Python environment, you can also use statistical clustering methods, counting the number of letters based on the distribution of X coordinates.
import matplotlib.pyplot as plt
# Assume the coordinate lists have already been parsed
x_coords = [...]
y_coords = [...]
plt.figure(figsize=(12, 4))
plt.plot(x_coords, y_coords, 'b-', linewidth=0.5)
plt.axis('equal')
plt.savefig('toolpath.png')
After running this code, you'll see lines resembling handwriting, with each letter occupying its own distinct X range. Then you can guess by comparing against common font shapes. If some letters are connected, you can also use path continuity analysis to see which strokes are linked together.
Common pitfalls, summarized for you
The skill documentation includes a particularly useful table, which I've directly borrowed as a cheat sheet:
- Pitfall 1: Relying on the file name. File names are arbitrary and don't represent the content, so don't trust them.
- Pitfall 2: Only searching for comments. The text is in the coordinates, not in the comments; comments are only useful for locating sections.
- Pitfall 3: Directly saying "cannot determine." Don't be lazy—as long as the data is there, you can always find the answer through visualization or clustering methods.
- Pitfall 4: Treating M486 tags as content. Tags are for partitioning, not the content itself.
What if you can't plot graphs?
Don't worry—the skill offers a backup plan. You can perform statistical distribution analysis, plotting a histogram of the X coordinates, where each peak represents the width of a letter. Alternatively, you can do bounding box extraction, finding the min/max coordinates of each continuous path segment, which gives you a rough estimate of the letter count. You can even simulate with ASCII art, mapping coordinates onto a character grid and marking visited points with '#' symbols—you'll still be able to see the shapes.
Installation and usage
This skill is hosted on GitHub, named gcode-to-text, by the author Zurybr. Installation is simple—just use the npx command:
npx skills add https://github.com/Zurybr/lefarma-skills --skill gcode-to-text
Once installed, you can invoke it in any supported environment. The entire analysis process is mostly automated—you just provide the G-code file path, and it will extract the coordinates, generate visualization plots, and then provide the interpreted results. For those without a programming background, don't worry—the skill also comes with helper scripts, like extract_coordinates.py and visualize_toolpath.py. You can simply run these scripts to generate the plots.
Final thoughts
Honestly, when I first saw this skill, I felt it was a bit like "using a sledgehammer to crack a nut"—isn't it just printing a few letters? Why make such a fuss? But after actually using it, I realized that in manufacturing, many times the G-code files you receive don't even have comments...