# Generating G-code

Last updated: October 25, 2026

G-code is the program that tells the CNC machine, line by line, how to cut the parts and where to drill and cut grooves; moducut writes this program from nested sheets. This page walks through the Create CNC Production File flow step by step.

> **Short answer** Check the machine and cutters in **Settings › CNC Settings**. Open Nesting Settings with **Production › Nesting** and press **Run Nesting**. In Nesting Results, choose **Save All G-Code** or **Send This Board to Production**, choose the machine and press **Export G-Code**.

## Step by step

1. In Nesting Results, press **Save All G-Code**; for a single sheet only, use **Send This Board to Production**.
2. In the Create CNC Production File window, choose the machine in the CNC Machine / Post Selection section. **CNC/Tool Settings** opens the CNC Settings window.
3. The operation list shows the jobs on the sheets row by row: Back Panel Groove, Drilling by hole diameter and Outer Cut (Profile). You can turn each row on or off and choose its tool.
4. For grooves, choose Single Pass or Pocket Clearing on the Pass row; for sizing, With contour or Without contour.
5. If you like, watch the program with **Simulation** before sending it to the machine.
6. Press **Export G-Code**.

If the project has no name, a Project Save Required warning appears first; press **OK**, enter the project name and customer name in Project Info and continue with **Save**. A wait window appears while the program is prepared; when it is done, the number of G-code files created is reported.

## Where are the files written?

G-code files are written without a save dialog and the folder opens on its own. The default root folder is the Moducut CNC folder on the Desktop; if a Production Line is active, its output folder is used. Each output is written to a new folder named with the date and seconds, inside a folder named after the project; old outputs are not deleted.

**Output folder**

~~~text
Moducut CNC/
  KITCHEN/
    20261025_143012/
      project.mbz
      metadata.json
      gcode/
        material folder/
~~~

The folder also holds a copy of the project at that moment (project.mbz) and an info file (metadata.json); programs are split by material in the gcode folder. Folder and file names are written without Turkish characters or spaces so CNC software can read them.

## Warnings and confirmations

- **Holes Outdated.** If a connector, hardware or general setting changed after nesting, Export G-Code asks for confirmation first: **Redo nesting** lays the sheets out with current settings, **Export anyway** gets the program with the old holes, **Cancel** goes back.
- **Holes Do Not Match the Model.** As a final safety step, moducut checks whether every hole on the sheet is where it is in the current 3D model; if any hole does not match, it asks for separate confirmation.
- **Single tool mode.** Jobs assigned to another cutter are written with one cutter, with a warning.

## Back-side programs

For parts with blind holes or grooves on face B, moducut prepares a separate back-side program. This program has only the face B drilling and groove commands, with no sizing. You flip the part over its long edge and push it against the machine’s zero corner; the instructions are written at the start of the program. Save the programs one by one from the Back-Side Programs section in Nesting Results, or all together with **Save All Reverse Programs**.

## Production line

In the **Production › Production Line Setup** window, type the line name and make the line active. On the Machines tab, add drilling and panel sizing machines, and choose a cut list profile and part categories for each sizing machine. On the Barcode and Output tab, set the barcode scheme, output folder and folder name pattern ({proje}, {tarih}, {saat}). While the line is active, G-code is written in this layout and the sizing machines’ cut lists are added. **Export Profile…** and **Import Profile…** move the line to another computer.

> **Tip:** Before sending to the machine, watch the program step by step with the [Cutting simulation](/en/docs/simulation/cutting-simulation/); the simulation runs from the very program that will be written.

## Frequently asked questions

### Which machines does the G-code work on?

moducut writes G-code for the machine profile and post template you choose in CNC Settings. If your machine is not among the ready profiles, create a copy of the closest profile with Add New and edit the header, tool change and end lines.

### If I export G-code from the same project a second time, is the old one deleted?

No. Each output is written to a new folder named with the date and seconds; earlier folders stay as they are.

### Why do I need to run nesting first?

G-code is written from parts laid out on sheets; nesting decides where on the sheet each part is cut. Without nesting there are no sheets to produce.
