OpenSCAD .csv driven batch exporter
by tdeagan, published
Use This Project
Give a Shout Out
If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.Print Thing Tag
here is a Python script that will execute a batch series of OpenSCAD command lines driven from a .csv file. You can use it to generate a set of images, a set of .STLs or whatever formats are now or future supported.
It uses OpenSCAD's -D capability to populate variables on the command line. Since OpenSCAD determines the output format from the extension of the output filename, that is driven from the .csv as well.
The .CSV would would like this:
FILE,ARGS,able, baker, charlie
for an OpenSCAD file like this:
able = 10;
charlie = 10;
on Debian, the command
python3 openscad_batch.py -x params.csv test.scad
would generate (and optionally execute if the -x was missing,) a series of command lines like this:
openscad --render --projection=o -D "baker=20" -D "able=10" -D "charlie=30" -o test1.png test.scad
openscad -D "baker=30" -D "able=20" -D "charlie=40" -o test2.stl test.scad
- openscad -D "baker=40" -D "able=30" -D "charlie=50" -o test3.stl test.scad
- it's Python 3 (sorry, but I've moved on. 3 is the future.)
- it needs a recent version of OpenSCAD to be able to do things like render (see OpenSCAD docs for a list of which command line switches each version of OpenSCAD supports.
- call it with -h to get instructions (you can also read them in the source below
- I've tested on Windows 8.1 and Debian 64 bit
Here's the help it generates:
usage: openscad_batch.py [-h] [-x] CSV OPENSCAD_FILE Run OpenSCAD repeatedly with parameters driven from a .csv file. ---------- USAGE NOTES ---------------- * First _row_ of .csv contains paramter names (i.e. OpenSCAD constants) NOTE: do not enclose parameter names in quotes. * First _column_ of first _row_ must be named FILE. * First _column_ of subsequent rows must contain output file name for that row's values and be in double quotes (e.g. "cube1.stl") * Second _column_ of first _row_ must be named ARGS * Second _column_ of subsequent rows must contain OpenSCAD cmd line args for that file output or be empty (e.g. ,"--render", for a .png output or ,, for a line with no args) * String values in subsequent rows must be enclosed in double quotes. * OpenSCAD executable must be in the PATH positional arguments: CSV location of .csv file containing params OPENSCAD_FILE name of OpenSCAD file (without args) optional arguments: -h, --help show this help message and exit -x Don't execute command line (just send output to console) EXAMPLE COMMANDS: c:python34python openscad_batch.py params.csv cubeout.scad python openscad_batch.py -x params.csv cubeout.scad (linux) python3 openscad_batch.py params.csv cubeout.scad EXAMPLE .CSV FILE: FILE,ARGS,able,baker,charlie "cube1.png","--render",10,20,30 "cube2.stl",,20,30,40 "cube3.stl",,30,40,50 works with .scad file: able = 10; baker= 10; charlie = 10; cube([able,baker,charlie]);
Upgrade this Thing with Thingiverse Apps
OpenSCAD .csv driven batch exporter by tdeagan is licensed under the Creative Commons - Attribution - Share Alike license.
What does this mean?
- You must attribute (give credit) to the creator of this Thing.
- You must distribute Remixes under the same license as the original.
- Remixing or Changing this Thing is allowed.
- Commercial use is allowed.
Show Some Love
Say thanks by giving tdeagan a tip and help them continue to share amazing Things with the Thingiverse community.Tip Designer
We're sure tdeagan would love to see what you've printed. Please document your print and share a Make with the community.
To post a Make simply visit this Thing again and click I Made One to start uploading your photo. It’s even easier to post a Make via the Thingiverse Mobile app (available via Google Play and Apple App Store).