Exclude object lets you drop one failed part and keep printing the rest. It needs a config section, labeled G-code and nothing else. Below are the settings, the commands, two optional macros and the fixes for when no objects show up.
Klipper’s exclude object needs no macro. Add an empty [exclude_object] section to printer.cfg, then print G-code that carries object labels, from your slicer or from Moonraker’s enable_object_processing. Mainsail and Fluidd then cancel a part by sending EXCLUDE_OBJECT NAME=<name>; a macro only adds shortcuts, such as cancelling the current object or accepting Marlin’s M486.
How do you enable exclude object in Klipper?
Add an empty [exclude_object] section to printer.cfg and restart Klipper. Then get object labels into the G-code: set your slicer to write Klipper’s EXCLUDE_OBJECT commands, or set enable_object_processing: True under [file_manager] in moonraker.conf. Re-slice and re-upload afterwards, because files made before the change carry no labels.
# printer.cfg
[exclude_object]
The section takes no options. Klipper’s configuration reference shows it bare.
How to set up exclude object in Klipper and your slicer
- Add the config section. Put
[exclude_object] in printer.cfg, save and restart Klipper.
- Label objects in the slicer. Use the native setting for your slicer from the table below.
- Or let Moonraker add the labels. If your slicer has no Klipper option, add
enable_object_processing: True to [file_manager] in moonraker.conf and restart Moonraker.
- Re-slice and upload. Only files sliced or uploaded after the change carry the labels.
- Check during a print. Mainsail shows an exclude button in the status panel. Fluidd puts a cancel icon in its G-code viewer.
| Slicer |
Where to turn it on |
| PrusaSlicer 2.7.0 or newer |
Printer Settings > General > G-code flavor: Klipper, then Print Settings > Output options > Label objects: Firmware-specific |
| OrcaSlicer |
Printer Settings > G-code flavor: Klipper, then Process > Others > G-code output > Exclude objects |
| SuperSlicer, Cura, ideaMaker |
No native Klipper output: use Moonraker processing (in SuperSlicer, also turn on Print Settings > Output options > Label objects) |
The labeled file opens with one EXCLUDE_OBJECT_DEFINE per part, then wraps each part’s moves on every layer in EXCLUDE_OBJECT_START and EXCLUDE_OBJECT_END.
Moonraker enable_object_processing
enable_object_processing makes Moonraker rewrite slicer object comments into Klipper commands while it reads an uploaded file. It defaults to False.
# moonraker.conf
[file_manager]
enable_object_processing: True
Moonraker skips any file that already contains EXCLUDE_OBJECT_DEFINE, so leaving it on next to a native slicer setting does no harm. It reads the object comments that PrusaSlicer-based slicers (Label objects set to OctoPrint comments), Cura and ideaMaker write. It also converts M486 lines. Moonraker’s documentation warns the step is “file I/O intensive” and “not recommended for usage on low resource SBCs such as a Pi Zero.” On such a board, run the preprocess-cancellation script as a slicer post-processing step instead.
Klipper EXCLUDE_OBJECT commands
| Command |
What it does |
EXCLUDE_OBJECT NAME=<name> |
Stops printing the named object |
EXCLUDE_OBJECT CURRENT=1 |
Stops printing the object being printed now |
EXCLUDE_OBJECT |
Lists the objects excluded so far |
EXCLUDE_OBJECT RESET=1 NAME=<name> |
Un-excludes one object; RESET=1 alone clears the list |
EXCLUDE_OBJECT_DEFINE |
Lists the objects Klipper knows; add JSON=1 for full details |
Klipper stores names in upper case and replies Excluding object <NAME> in the console. It warns that un-excluding “can cause print failures, if layers were already skipped.” The list resets at the start of every print, so nothing carries over to the next job. Macros read the module’s state as printer.exclude_object, with the fields objects, excluded_objects and current_object.
A macro to cancel the current object
EXCLUDE_OBJECT CURRENT=1 raises “There is no current object to cancel” whenever the toolhead is between parts. This wrapper checks first, so a dashboard button or macro shortcut never errors mid-print:
[gcode_macro CANCEL_CURRENT_OBJECT]
description: Exclude the object being printed now
gcode:
{% if 'exclude_object' not in printer %}
{action_raise_error("[exclude_object] is not enabled")}
{% endif %}
{% set current = printer.exclude_object.current_object %}
{% if current %}
EXCLUDE_OBJECT NAME={current}
{% else %}
{action_respond_info("No object is printing right now")}
{% endif %}
current_object follows the G-code Klipper has read, and Klipper “looks ahead to process upcoming gcode”. On small parts it can already name the next object, so check the object name in the console reply. For the {% if %} syntax, see if/else in macros.
M486 macro for Marlin-style cancel commands
Klipper has no M486, the cancel command Marlin and RepRapFirmware use. Klipper’s config/sample-macros.cfg ships a [gcode_macro M486] that translates it: T defines a count of objects, S starts one, P cancels by index, C cancels the current one and U un-cancels. Copy it from that file only if your G-code or screen sends M486. Klipper-labeled files need no M486 macro.
Why exclude object is not working in Klipper
- No objects show in Mainsail or Fluidd. The file has no labels. Re-slice with the slicer setting on, or re-upload after enabling Moonraker processing. Run
EXCLUDE_OBJECT_DEFINE during the print: an empty list confirms the file has no labels.
- The console shows
Unknown command:"EXCLUDE_OBJECT_DEFINE". The [exclude_object] section is missing or Klipper was not restarted. Klipper only reports unknown commands and prints on, so nothing gets excluded.
- Some slicer features conflict. PrusaSlicer and OrcaSlicer both state labeling is “NOT compatible with Single Extruder Multi Material setup and Wipe into Object / Wipe into Infill.”
- Supports keep printing after you cancel. Mainsail notes that Cura and ideaMaker treat support “as a single non-mesh entity”, so an object’s supports still print.
- Old software. Mainsail lists Klipper v0.10.0-438, Moonraker v0.7.1-445 and Mainsail v2.1.0 as the minimum versions.
The same object definitions size the mesh when you run BED_MESH_CALIBRATE ADAPTIVE=1, so a labeled file is also what adaptive bed meshing needs.