Ir para conteúdo
3DFinder
Entrar

Você está no 3DFinder

Buscamos em Thingiverse, MakerWorld e Printables ao mesmo tempo para te dar o melhor de cada uma.

Buscar mais como este
Modelo 3D OpenSCAD .csv driven batch exporter por tdeagan no Thingiverse

Descrição

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
"test2.stl",,20,30,40
"test3.stl",,30,40,50

for an OpenSCAD file like this:
able = 10;
baker= 10;
charlie = 10;
cube([able,baker,charlie]);

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

Notes:

  • 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]);
```

Thingiverse

OpenSCAD .csv driven batch exporter

16
Curtidas
0
Downloads
17
Coleções
Tags
batch command line openscad openscad tool python
Licença Creative Commons - Attribution - Share Alike
Ver no Thingiverse (abre em nova aba)