simplyKeeb-60K

1.7 KBPY
build.py
1.7 KB40 lines • python
1import os
2from decimal import Decimal
3from shutil import which, rmtree
4
5buildPath = "./.build"
6
7print("HotKeep Generator V1")
8print("created by Gerrit 'Geaz' Gazic")
9print()
10
11if which("openscad") is None:
12    print("OpenSCAD was not found! Please make sure that it is in your PATH!")
13    exit()
14
15switchHoleClearance = Decimal(input("Enter your switch hole clearance [0.1] : ") or "0.1")
16printClearance = Decimal(input("Enter your print clearance [0.2] : ") or "0.2")
17smallSocketClearance = Decimal(input("Enter your small hole socket clearance (used for anything smaller than 1.5mm on the hotswap socket). [0.7] : ") or "0.7")
18
19if os.path.isdir(buildPath):
20    rmtree(buildPath)
21os.mkdir(buildPath)
22
23files = [
24    {"input":"1 - Hotswap Socket.scad", "output":"1 - Hotswap Socket.stl" },    
25    {"input":"2 - Hotswap Board.scad", "output":"2 - Hotswap Board.stl" },
26    {"input":"3 - Plate.scad", "output":"3 - Plate.stl" },
27    {"input":"4 - Top Layer.scad", "output":"4 - Top Layer.stl" },
28    {"input":"5 - Middle Layer.scad", "output":"5 - Middle Layer.stl" },
29    {"input":"6 - Bottom Layer.scad", "output":"6 - Bottom Layer.stl" },
30    {"input":"7 - Pro Micro Mount.scad", "output":"7 - Pro Micro Mount.stl" }
31]
32
33with open('.build/params.txt', 'w') as f:
34    f.write("switchHoleClearance={}\n".format(switchHoleClearance))
35    f.write("printClearance={}\n".format(printClearance))
36    f.write("smallSocketClearance={}\n".format(smallSocketClearance))
37
38for i in files:
39    print("Creating {} ...".format(i["output"]))
40    os.system("openscad -q -D switchHoleClearance={} -D printClearance={} -D smallSocketClearance={} -o \"./{}/{}\" \"{}\"".format(switchHoleClearance, printClearance, smallSocketClearance, buildPath, i["output"], i["input"]))