-
Notifications
You must be signed in to change notification settings - Fork 11
/
gen_samples.py
37 lines (31 loc) · 1.03 KB
/
gen_samples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
import subprocess
import csv
import os
import platform
if platform.system() == 'Windows':
OPENSCAD = 'C:\Program Files\OpenSCAD\openscad.exe'
elif platform.system() == 'Linux':
OPENSCAD = 'openscad'
else:
OPENSCAD = '/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD'
MYDIR=os.path.dirname(os.path.realpath(__file__))
def gen_samples(file=f"{MYDIR}/samples.csv"):
os.makedirs(f"{MYDIR}/stl", exist_ok=True)
with open(file, '+r') as f:
data = csv.reader(f)
for l in data:
print("Processing:", l)
filename = "stl/" + "_".join(l) + ".stl"
subprocess.run(
[OPENSCAD,
'-o', filename,
'-D', f'BRAND="{l[0]}"',
'-D', f'TYPE="{l[1]}"',
'-D', f'COLOR="{l[2]}"',
'-D', f'TEMP_HOTEND="{l[3]}"',
'-D', f'TEMP_BED="{l[4]}"',
f'{MYDIR}/FilamentSamples.scad',
], check=True)
if __name__ == "__main__":
gen_samples()