Skip to content

others_settings_g_code_output

github-actions[bot] edited this page Oct 15, 2026 · 13 revisions

G-Code Output

These settings control how G-code is generated and formatted. They impact readability, file size, print behavior, and compatibility with firmware and post-processing tools.

Reduce Infill Retraction

Mode: Advanced.
Variable: reduce_infill_retraction.
Type: Boolean.
CLI Example: --reduce-infill-retraction=1.
When enabled, the slicer will skip retractions for travel moves that occur entirely inside infill regions. This reduces the number of retractions and can speed up printing for complex models, but it may increase oozing or stringing inside infill. Slicing time may also increase slightly.

Recommended when internal cosmetic quality is not critical and you want fewer retractions.

Add line number

Mode: Developer.
Variable: gcode_add_line_number.
Type: Boolean.
CLI Example: --gcode-add-line-number=1.
Prefix each G-code line with a sequential line number (N1, N2, ...). Useful for debugging or tools that expect numbered G-code.

Verbose G-code

Mode: Advanced.
Variable: gcode_comments.
Type: Boolean.
CLI Example: --gcode-comments=1.
Include descriptive comments for G-code lines and blocks to make the file human-readable and easier to debug.
Verbose mode produces much larger files and may slow down SD-card printing on some printers.

Label Objects

Mode: Advanced.
Variable: gcode_label_objects.
Type: Boolean.
CLI Example: --gcode-label-objects=1.
Insert comments that label moves with the object they belong to (object index or name). This is useful for integrations such as OctoPrint's Cancel Object plugin and for human inspection of the G-code.

Exclude Objects

Mode: Advanced.
Variable: exclude_object.
Type: Boolean.
CLI Example: --exclude-object=1.
Add commands to the G-code that define each object and mark where it starts and ends, so the printer firmware can skip (cancel) individual objects during the print: EXCLUDE_OBJECT_DEFINE, EXCLUDE_OBJECT_START and EXCLUDE_OBJECT_END for Klipper, and M486 for Marlin and RepRapFirmware.

Filename Format

Mode: Advanced.
Variable: filename_format.
Type: Text.
CLI Example: --filename-format={input_filename_base}_{filament_type[initial_tool]}_{print_time}.gcode.
Define a filename template for exported G-code. Templates may include tokens like project name, date, or other metadata to produce consistent and informative filenames on export.

For example:

{input_filename_base}_{filament_type[initial_tool]}_{print_time}.gcode

This can be used to generate filenames like OrcaCube_PLA_1h15m.gcode.

Tip

Check Filename Templates for available tokens and their meanings.

Change extrusion role G-code

Mode: Advanced.
Variable: process_change_extrusion_role_gcode.
Type: Text.
CLI Example: --process-change-extrusion-role-gcode=value.
This G-code is inserted when the extrusion role is changed.
This is the process version of the Change extrusion role G-code that is also available in the Material settings and Printer settings, and it runs after both of them.

Tip

Read the Printer settings for more details and examples.

Clone this wiki locally