Files
OrcaSlicer/tests
Ian Bassi c0e6db227d Export G-code statistics as JSON (#16487)
* Export G-code statistics as JSON

Add an export of a plate's G-code statistics for scripts and
spreadsheets that compare prints or settings: print time, travel,
filament and feature totals, the same per layer, and the filament of
each object instance and its supports. The times are the preview's
estimates, summed the way the preview sums them.

The GUI writes <name>.statistics.json next to an exported G-code when
"Export statistics with G-code" is enabled in Preferences (Control >
Slicing). The CLI writes plate_N.statistics.json to the output directory
with --export-statistics, and exits with -25 when it cannot.

The per-instance masses now carry the object's name and the instance's
index, so the export can name them. The vertices the processor adds
inside a move for the actual speed view repeat the move's extrusion, so
the filament sums skip them.

* Move the statistics export preference to the Developer tab

"Export statistics with G-code" now sits in Developer > Settings
instead of Control > Slicing.

* Store the G-code statistics inside exported 3MF files

With the preference on, an exported sliced 3MF file holds each plate's
statistics as Metadata/plate_N.statistics.json, next to its G-code. The
print job sent to a printer and the autosave backup leave them out.

The CLI does the same with --export-3mf, and writes the separate file
only next to the G-code in --outputdir, as without it the G-code is a
temporary file. The file is written in binary mode, so it reads the
same on every platform and matches the copy in the 3MF.

* Address review of the statistics export

- Number each object instance by its position among its model object's
  copies. A copy of another rotation or scale, and every copy on a belt
  printer, slices as a print object of its own, where it was always
  instance 0; a copy after a non-printable one shifted too.
- Take the filament totals from the processor's statistics, which count
  the flush as the preview's filament table does, and list each
  filament's model, support, prime tower and flush use. The summary's
  cost is now filament_cost, as the preview's cost adds the time cost.
- State when the version goes up.
- Drop the preference's default, which get_bool already gives.
2026-10-14 14:22:04 -03:00
..
2025-12-08 22:42:11 +08:00

OrcaSlicer tests

Building, running and writing tests is documented on the wiki, under How to Test.

Two files here rather than there, because coding agents only read what is in the repository:

  • AGENTS.md is the same guidance in short form, and is what an agent working under tests/ picks up.
  • CATCH2.md is the Catch2 reference, including the mistakes that break a test at runtime.