Batch export models from parametric OpenSCAD designs using CSV or Customizer JSON parameter sets.
One .scad model plus a list of parameter sets gives you one output file per set per output
format — in any format OpenSCAD can write, several at a time, with a machine-readable record of
what happened.
scadbatch export model.scad params.csv out/
No Python dependencies — just Python 3.10 or newer and OpenSCAD. The GUI additionally needs
tkinter, which some Linux distributions package separately (python3-tk on Debian and Ubuntu);
the standalone binaries bundle it.
pip install scadbatch
Or download a standalone binary for Windows, macOS or Linux from Releases — no Python needed.
OpenSCAD itself is not bundled. Install it from openscad.org
and either put it on PATH, set $OPENSCAD, or pass --openscad-path.
A parameter file, one row per model:
exported_filename,width,height,depth
cube_small,10,10,10
cube_medium,20,20,20
cube_large,30,30,30Export every row:
scadbatch export examples/simpleCube/simpleCube.scad examples/simpleCube/simpleCube.csv out/
Three STLs in out/, named from the first column. A parameter the file does not mention keeps
the default from the .scad file, so list only what varies.
To see the OpenSCAD command line for each case without running anything, add --dry-run.
from scadbatch import batch_export, detect_engine
engine = detect_engine()
result = batch_export(
scad_file="examples/simpleCube/simpleCube.scad",
parameter_file="examples/simpleCube/simpleCube.csv",
output_folder="out",
openscad_path=engine.path,
export_format="binstl",
selection="0-1",
sequential=False,
formats=("stl",),
jobs=2,
)
for r in result.results:
print(f"{r.name:14} {r.format} ok={r.ok} {r.duration:.2f}s {r.output_path}")
print(f"failures={len(result.failures)} with_errors={len(result.with_errors)}")cube_small stl ok=True 0.03s out/cube_small.stl
cube_medium stl ok=True 0.03s out/cube_medium.stl
failures=0 with_errors=0
The library configures no logging handlers of its own, so add logging.basicConfig() to see the
progress messages the CLI prints.
scadbatch gui
Select the .scad file, the parameter file and an output folder; set the output formats, the
STL flavour, a selection range and the parameter file's encoding; watch the log; and convert
between CSV and JSON. The command line still covers dry runs, timeouts, parallelism, the run
summary, name templates and the image options.
- docs/parameters.md — the CSV and JSON formats, what a blank cell means, how a cell becomes an OpenSCAD literal, how output files are named, and what is refused
- docs/execution.md — parallelism, formats, timeouts, skipping existing output, and the run summary JSON
- docs/related-tools.md — the other tools that do this, what each is good at, and when a shell loop is the right answer
| command | what it does |
|---|---|
scadbatch export <scad> <params> <out/> |
export one file per parameter set per output format |
scadbatch csv2json <csv> <json> |
CSV to a Customizer parameter-set file |
scadbatch json2csv <json> <csv> |
and back |
scadbatch gui |
the graphical interface |
scadbatch <command> --help lists every flag. The ones worth knowing early:
| flag | |
|---|---|
--format EXT |
stl, off, 3mf, png, csg, … Repeat for several at once |
--select |
which sets to export: 0-5, 1-3,7, every:2 in 0-10, from:5 |
-j N, --jobs N |
how many OpenSCAD processes at once |
--dry-run, -n |
print the commands, run nothing |
--timeout SECONDS |
kill a case that hangs, keep the batch going |
--summary run.json |
record the run for CI to assert against |
--name-template |
e.g. '{name}_d{diameter}', 'part_{index:03d}' |
The conversions read values with the same rules the exporter uses, so a cell means the same
thing either way. Converting to JSON is lossy for the types current OpenSCAD builds ignore in a
parameter-set file: only a flat vector of numbers survives, so a vector of strings or booleans, a
nested vector, a range and undef are each warned about by name. Export the CSV directly to
apply those.
For a few numeric parameters, a shell loop is fine, and docs/related-tools.md shows one. The reasons to reach for a tool are all the same reason: OpenSCAD exits 0 when it does the wrong thing.
- A misspelled parameter is simply never used, so a typo in a column name gives you a full set of outputs built at the defaults, exit 0, no message.
- Reading a parameter set, a value it cannot convert to the parameter's declared type is ignored and the default stands, silently.
-Dtakes an OpenSCAD expression, not a value, so-D msg=hellosetsmsgto undef.- Several
ERROR:conditions — an unreadable parameter file, a font file it cannot read — print an error and still exit 0. A missing font family prints nothing at all and substitutes.
So parameter files that OpenSCAD would misread are refused up front, with a message naming the
file and the place in it; values are serialised through one documented set of rules; and
--summary records per-case status plus counts.errors, which counts cases that printed an
error whatever the exit status, so CI has something to gate on.
examples/ has four projects, each with a .scad, a .csv and a .json:
simpleCube |
a cube in three sizes — the smallest thing that shows the idea |
candleStand |
from the OpenSCAD parametric examples |
sign |
adjustable message, size and resolution, same source |
gridfinity |
189 parameter sets, and the one that shows the point at scale. Needs gridfinity-rebuilt-openscad installed as an OpenSCAD library — see its own README |
Models and projects this has been used on:
- SnapTessSCAD
- Open Source Nasopharyngeal Swab and UV Curing System — HardwareX paper
- Customizable Christmas Name Ornament — after the original by Lyl3
- the
candleStandandsignparametric examples above
Contributions are welcome, and a bug report with a reproduction is as useful as a patch.
- CONTRIBUTING.md — setting up, the checks to run, and how changes are organised: one issue, one branch, one pull request
- SUPPORT.md — where to ask, what to include, and what response to expect
- CODE_OF_CONDUCT.md — Contributor Covenant 2.1
- CHANGELOG.md — what changed in each release, with the pull request behind each entry
- docs/releasing.md — how a release is cut
CITATION.cff carries the metadata GitHub's "Cite this repository" button reads. A DOI will be added once a release is archived on Zenodo.
This started as a Python port of OutwardBuckle/OpenSCAD-Bulk-Export, and also took ideas from 18107/OpenSCAD-batch-export-stl. docs/related-tools.md says what each does and when to prefer it.
AGPL v3. See LICENSE.