--outputdir
<dir>Redirect every output file the CLI produces — G-code, 3MF (when --export-3mf is used), PNG renders, and result.json — into a single pre-existing directory, replacing the otherwise scattered per-temp-path or working-directory defaults.
Details
--outputdir sets the directory into which all files produced by a CLI run are written. When it is set, the slicer routes every output type through that single path rather than scattering files across the process's working directory or internal temp paths.
The directory is used concretely in several places. During a slice run, per-plate G-code files are written as plate_<N>.gcode directly inside the directory. When --export-png is also active, the rendered PNG files land there as plate_<N>_<camera_view_integer>.png, where the integer is the numeric value of the --camera-view parameter. When --export-3mf is used, the slicer prepends this directory to the filename passed to that flag (which defaults to output.3mf). The result.json exit-status file, which the slicer always writes on both success and failure, also goes into this directory; if --outputdir is not given, result.json is written into the process's working directory instead.
For model-conversion actions (export-to-OBJ or export-to-STL outside of slicing), the behavior has one nuance: the path is checked at resolution time to determine whether it points to an existing directory. If the path is an existing directory the slicer appends the auto-generated filename into it; if the path does not resolve as a directory it is treated as a filename stem and the appropriate extension is appended to it directly.
For per-object multi-file exports (specifically STL, which exports one file per model object), the slicer creates a format-specific subdirectory — stl/ for STL — inside the given directory automatically. The underlying file-routing function also defines this logic for obj/, 3mf/, and amf/ subdirectory types, though those code paths are not currently reached through the active export-models dispatch.
Watch out for
- ▲ The directory must already exist before the CLI run begins. The slicer creates format-specific subdirectories for per-object model exports, but it does not create the top-level `--outputdir` path itself. A missing directory causes file-write failures rather than a clean error.
- ▲ Because `result.json` is always written to this directory (or to the working directory when the flag is absent), automation that reads `result.json` to get the exit code and plate metadata must target the same location it passed to `--outputdir`.
- ▲ When the value does not point to an existing directory, the model-export code path treats it as a filename prefix rather than a directory. This matters only for non-slice export actions; during slicing and 3MF export the value is used as a raw path prefix unconditionally.
Sign up for free today
No credit card required. Connect unlimited printers and get production automation running in minutes.