-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslice_all.py
30 lines (21 loc) · 885 Bytes
/
slice_all.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
import os
import pathlib
from utils import slice_stl, print_msg
from settings import STL_DIR, GCODE_DIR
def slice_all_func():
stl_files = os.listdir(STL_DIR)
gcode_files = os.listdir(GCODE_DIR)
for stl_file in stl_files:
stl_path = pathlib.Path(os.path.join(STL_DIR, stl_file))
if stl_path.suffix != '.stl':
raise Exception(f'Invalid file in STL directory: {stl_file}. It\'s not STL file.')
print_msg(f'Processing file: {stl_file}')
gcode_file = str(stl_path.stem) + '.gcode'
if gcode_file in gcode_files:
print_msg(f' - Skipping, Gcode already exists.')
else:
gcode_path = os.path.join(GCODE_DIR, gcode_file)
print_msg(f' - Going to generate new gcode file: {gcode_path}')
slice_stl(stl_path, gcode_path)
if __name__ == '__main__':
slice_all_func()