Retour au blog
Guides19 November 20255 min read

Using G-code Metadata for Accurate 3D Print Quotes

DanielFounder, Printforge
G-codequotingautomationslicing

Every time you slice a 3D model, your slicer software embeds a wealth of information in the G-code file — estimated print time, filament usage, layer count, temperatures, and print settings. Most people ignore this metadata entirely, but it's incredibly valuable for generating accurate, automated quotes. Here's how to leverage it.

What's in a G-code File?

G-code files contain the machine instructions for your printer, but they also include comment lines (starting with a semicolon) that contain metadata about the print. Different slicers format this differently, but common fields include: estimated print time, estimated filament usage (in grams or metres), filament type, layer height, infill percentage, nozzle temperature, bed temperature, and the slicer name and version. This data is generated from the actual toolpath calculations, making it more accurate than rough estimates based on part volume alone.

Slicer-Specific Formats

Each slicer writes metadata in its own format. Bambu Studio and OrcaSlicer include detailed metadata at the start of the file in a structured comment block — total filament weight, type, colour, estimated time broken down by feature (perimeters, infill, supports). PrusaSlicer embeds similar data in comments at the end of the file, including a detailed statistics block. Cura places metadata in the header with fields like TIME, Filament used, and Filament weight. Understanding these formats lets you parse the data programmatically.

From Metadata to Quotes

With parsed G-code metadata, you can automate the most tedious part of quoting: calculating material cost and machine time. Instead of manually checking slicer estimates and typing numbers into a spreadsheet, you upload the G-code file and the system extracts the print time, material weight, and material type automatically. Apply your machine hourly rate to the time, your per-gram cost to the material weight, add your labour and overhead, and you have an accurate quote in seconds.

This approach is particularly powerful for repeat customers who send pre-sliced files. Rather than asking them for print details, you can extract everything directly from the file they provide. It also ensures consistency — every quote is calculated from the same data source using the same formula, eliminating human error.

Implementing G-code Parsing

Building a G-code parser doesn't require complex file processing. Since the metadata is in comment lines, you only need to read the text content of the file and match patterns for each slicer format. A typical parser reads through comment lines, identifies the slicer from header information, then extracts the relevant fields based on known patterns for that slicer.

  • Read comment lines (lines starting with ; or containing metadata markers)
  • Identify the slicer software from header comments
  • Extract print time, filament weight, filament type, and layer height
  • Convert units as needed (metres of filament to grams based on material density)
  • Feed the extracted data into your costing formula automatically

Tools like Printforge include built-in G-code parsing that supports all major slicers, so you can upload a G-code file and have a quote generated automatically. If you're building your own system, focus on supporting the slicers your customers actually use rather than trying to cover every format from day one.

Try Printforge for free

Calculate costs, create quotes, and manage your 3D print business — all in one place.

Start free trial