Turns a sliced file back into the part: G-code, Bambu Studio / OrcaSlicer .gcode.3mf, Cura .ufp and
PrusaSlicer .bgcode in; a closed STL and a STEP solid out. It is a plug-in for
Twoo STEP CAD Toolbox, where it adds a G-code → STEP tab. It is kept in its own repository and does not
change the toolbox.

Source-available · Non-commercial — licensed under the PolyForm Noncommercial License 1.0.0.
Provided as is, with no warranty and no liability. Check rebuilt parts before relying on them.

📘 The whole manual and research notes as one PDF

The G-code → STEP tab after a run: the rebuilt block with its hole, 6 flat faces and 1 cylinder

Project started 2026-11-29 11:27.

What it does

You have the G-code of a part (or a sliced 3MF) but not the model. Unslice reads the printer's moves and rebuilds
the part:

  1. Every layer of the file is a cross-section of the model. Its outer wall is the model's surface moved inwards by half a line width, so the walls of each layer, filled and grown back out, are the exact outline of the part at that height, holes included.
  2. Supports, skirts, brims, prime towers and start-code purge lines are left out (tick a box to keep support or brim).
  3. The layers are stacked into a closed STL mesh. A slope comes back as a smooth ramp between layer centres, not as the printed staircase. Flat tops and bottoms come back flat, at the heights they were printed at.
  4. The STEP is built from the layers themselves: runs of layers with the same outline become one extruded slab (true planes, arcs and cylinders), and runs that change smoothly (a cone, a chamfer, a dome) become one lofted surface. Anything that cannot be built that way goes through the toolbox's own surface fitter on the mesh.

How it works, drawn from a real run on the T-shaped test part

The plain-English version is in HOW_IT_WORKS.md; the research notes, measurements and what was
tried and dropped are in docs/RESEARCH.md.

What exists, and what does not

Status
G-code from Cura, PrusaSlicer, OrcaSlicer, Bambu Studio, Simplify3D (labels read) built, tested on generated files only
G-code without labels (the part's inside is guessed) built, tested on generated files only
Arcs (G2/G3), relative/absolute E, inches, G-code without spaces built and tested
Bambu/Orca .gcode.3mf (any plate), Cura .ufp built, tested on files made by the test tool
PrusaSlicer .bgcode (deflate, heatshrink, MeatPack) built from the specification; never read a real PrusaSlicer file
One body per named object (Cura ;MESH:, ; printing object, Klipper EXCLUDE_OBJECT) built, lightly tested
Closed STL, thinned without opening it built and tested
STEP by layers (slabs + lofts), STEP by surface fitting, faceted STEP built and tested on the test parts
Real slicer output, vase mode, one-at-a-time printing, multi-material not tested
Windows and Mac launchers written, not run
Run on a 7th-gen i3 not measured (heartbeat, memory budget and stall limit are in place)

Start (try it)

You need Twoo STEP CAD Toolbox (0.11.4-wip or newer) unzipped somewhere. Unzip Unslice next to it (or
anywhere; the launcher asks once where the toolbox is and remembers it in toolbox-path.txt).

System Double-click
Linux Unslice-Linux.sh (choose Run)
Windows Unslice-Windows.bat
macOS Unslice-Mac.command (first time: right-click → Open)

The launcher starts the toolbox exactly as its own launcher does (first run downloads its private Python and
libraries), with Unslice loaded from this folder. Open the G-code → STEP tab, drop a sliced file, press
Unslice. The STEP and the STL (name_unsliced.step, name_unsliced.stl) go into the toolbox's Files folder, and so do the extra bodies below.
Nothing is copied into the toolbox. To use Unslice without the launcher, point the toolbox at the plugins folder:
TOSTEP_PLUGIN_PATH=/path/to/unslice/plugins.

The G-code → STEP tab

Drop-in zip (install or update on its own). Each release also carries unslice-dropin-<version>.zip: just the
plug-in folder (unslice/, with manifest.toml and a plugin.json in the drop-in format). Unzip it into any folder and
point TOSTEP_PLUGIN_PATH at that folder. Honest note: the current toolbox reads manifest.toml only and has no
drop-in installer, so plugin.json is there for a toolbox that gains one. Build it yourself with
python tools/pack_dropin.py.

Command line (from the toolbox folder, with TOSTEP_PLUGIN_PATH set as above):

python run_tostep.py unslice part.gcode # part_unsliced.step + part_unsliced.stl (+ _adhesion) python run_tostep.py unslice part.gcode --support-body # also part_unsliced_support.stl python run_tostep.py unslice plate.gcode.3mf --plate 2 --object bracket python run_tostep.py unslice part.gcode out.step --step surface --support 

Options

Option What it does
STEP from auto (default): layers if the part is built of flat steps and smooth slopes, otherwise surface. layers: slabs and lofts. surface: the toolbox's fitter on the rebuilt mesh. faceted: exact triangles.
also export support as its own body Saves support, raft, wipe tower and lines the file did not name as separate STLs (..._support.stl, ..._other.stl), lined up with the part, so you can delete them in your CAD program or slicer. Off by default (they are the slow ones). Skirt, brim and purge lines are always saved as ..._adhesion.step and .stl when the file has any. Needs a labelled file.
keep support / keep skirt, brim Draw those lines into the part as well.
move to the origin The footprint centred on X0 Y0, the bottom at Z0 (the bed position is written in the log). Off: the part stays where it was on the bed.
undo slicer size compensation On by default: where the file records elephant-foot, XY size, contour or hole compensation, the part comes back at the size it was designed (layers route).
only objects named Rebuild the objects whose name contains this text.
plate For a 3MF with several sliced plates (0 = the first).
Area from (advanced) outer walls (exact, needs labels) or every line (unlabelled G-code; gaps under 50 mm² filled).
Grid (advanced) Cell size of the mesh grid; 0 = half the line width, coarsened if the part is large for the memory there is.
STL triangles (advanced) Thin the mesh to about this many triangles (100,000), never opening it.

How good is it

Measured with tools/accuracy.py on parts whose true shape is known, sliced by
tools/fake_slicer.py in each slicer's dialect (2-core cloud Linux machine, through the
toolbox's command line):

Part Slicer dialect True volume STL volume STL size (mm) STEP route STEP faces STEP volume Time
block 30x20x10 with an 8 mm hole cura 5497.4 mm³ 5498.1 (+0.01 %) 30.00 x 20.00 x 10.00 layers 7 (6 plane, 1 cylinder) 5497.3 (-0.00 %) 3 s
same, hole written as G2/G3 arcs bambu 5497.4 mm³ 5498.1 (+0.01 %) 30.00 x 20.00 x 10.00 layers 7 (6 plane, 1 cylinder) 5497.3 (-0.00 %) 3 s
same, G-code with no labels plain 5497.4 mm³ 5468.7 (-0.52 %) 29.96 x 19.97 x 10.00 layers 23 (19 plane, 4 extruded surface) 5468.2 (-0.53 %) 5 s
T with overhangs and support bambu 1800.0 mm³ 1800.0 (+0.00 %) 30.00 x 10.00 x 10.00 layers 10 (10 plane) 1800.0 (+0.00 %) 2 s
frustum, R12 to R6, 15 mm (slope) prusa 3958.4 mm³ 3953.0 (-0.14 %) 23.92 x 23.92 x 15.00 layers 3 (2 plane, 1 B-spline) 3954.9 (-0.09 %) 5 s

One real print was measured too (not generated): a Cura "overhang test" arm, 244 layers, 20.6 x 47.8 x 48.8 mm, with
the numerals 10-70 engraved into its curved face. The layers route rebuilds it in about 65 seconds (plus about 30 s for
the STL) as one valid solid of 5,721 faces, 0.001 mm mean and 0.097 mm worst from the printed outlines, volume within
0.01 % of what the layers hold. The arm comes out as its printed layers, 0.2 mm steps with the numerals crisp, because a
smooth loft over it would have to skip the layers the numerals are in (0.2.5-wip). The STEP is large (21.5 MB).
Step recognition (0.2.7-wip): recognise reads the layers as samples of a smooth surface, fits it, and cuts the
engraving back in: about 2 min, one valid solid, smooth arm with the numerals kept (16 of 16 on the overhang test).

The overhang arm with engraving = recognise
Close-up: "10" cut back in on a tangent plane, "20" as the printed layers

Engraving option (0.2.6-wip): keep (default) gives that stepped, crisp result. fill fills engraving up to 1.2 mm
deep first and builds a smooth arm: about 40 s, 13 MB, 1,170 faces, numerals gone. Choose it in the drop-down or with
--engraving fill.
Before 0.2.3 the same file took about 24 minutes, because the layers route gave up and the toolbox fitted surfaces to
the mesh instead.

Since 0.1.1 the STL is the STEP's own tessellation whenever the layers route works (a few hundred to a few thousand
triangles, sizes exact), so the STL column now matches the STEP. The unlabelled file is the exception that shows
the limit of guessing: its outline is traced from the drawn area, good to about half a percent. When the layers
route cannot be used, the STL comes from the mesh route, which is about 0.03 mm generous on every side: half a
sub-cell of the grid plus the 1/64 level that keeps the saved STL closed (RESEARCH.md §5).
Numbers from the previous build (0.1.0) are in docs/HISTORY.md.

Files

plugins/unslice/ the plug-in (contract 1 of the toolbox: manifest.toml, run(job), a tab, a command)
Unslice-*.sh/.bat/.command the double-click launchers
tests/ python -m unittest discover -s tests (toolbox tests skip when the toolbox is not found)
tools/fake_slicer.py writes the test G-code; tools/accuracy.py the table above; tools/make_figures.py the picture
docs/ research notes, history, screenshots, the PDF manual

CHANGELOG · HISTORY · THIRD_PARTY · SECURITY ·
CONTRIBUTING

Relationship to other projects

Unslice is a plug-in of Twoo STEP CAD Toolbox and uses its STEP machinery (the mesh → STEP fitter and its
sketch fitter); the idea for the layers route comes from the toolbox's own slicer research. It overlaps
Unbox 3MF only in opening 3MF archives: Unbox 3MF takes meshes out of project files, Unslice takes G-code out of
sliced ones.

Source code: The-Dorkknight/unslice on GitHub