OpenSCAD .csv driven batch exporter

by tdeagan, published

OpenSCAD .csv driven batch exporter by tdeagan Dec 23, 2014


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

Thing Statistics

895Views 316Downloads


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
"test1.png","--render --projection=o",10,20,30

for an OpenSCAD file like this:
able = 10;
baker= 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)  

c:python34python openscad_batch.py params.csv cubeout.scad  
python openscad_batch.py -x params.csv cubeout.scad  

python3 openscad_batch.py params.csv cubeout.scad  


works with .scad file:  
able = 10;  
baker= 10;  
charlie = 10;  


All Apps

Upgrade this Thing with Thingiverse Apps

No results.