-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathmain.py
89 lines (84 loc) · 3 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import argparse
from gerber_to_scad import process_gerber
import gerber
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Convert gerber files to an scad 3d printable solder stencil."
)
parser.add_argument("outline_file", help="Outline file")
parser.add_argument("solderpaste_file", help="Solderpaste file")
parser.add_argument("output_file", help="Output file", default="output.scad")
# Optional arguments
parser.add_argument(
"-t",
"--thickness",
type=float,
default=0.2,
help="Thickness (in mm) of the stencil. Make sure this is a multiple "
"of the layer height you use for printing (default: %(default)0.1f)",
)
parser.add_argument(
"-n",
"--no-ledge",
dest="include_ledge",
action="store_false",
help="By default, a ledge around half the outline of the board is included, to allow "
"aligning the stencil easily. Pass this to exclude this ledge.",
)
parser.set_defaults(include_ledge=True)
parser.add_argument(
"-L",
"--ledge-thickness",
type=float,
default=1.2,
help="Thickness of the stencil ledge. This should be less than the "
"thickness of the PCB (default: %(default)0.1f)",
)
parser.add_argument(
"-g",
"--gap",
type=float,
default=0,
help="Gap (in mm) between board and stencil ledge. Increase this if "
"the fit of the stencil is too tight (default: %(default)0.1f)",
)
parser.add_argument(
"-i",
"--increase-hole-size",
type=float,
default=0,
help="Increase the size of all holes in the stencil by this amount (in "
"mm). Use this if you find holes get printed smaller than they should "
"(default: %(default)0.1f)",
)
parser.add_argument(
"--flip",
action="store_true",
help="Flip the stencil. Use this for making stencils for the bottom layer.",
)
args = parser.parse_args()
outline_file = open(args.outline_file, "r")
solderpaste_file = open(args.solderpaste_file, "r")
outline = gerber.loads(outline_file.read())
solder_paste = gerber.loads(solderpaste_file.read())
with open(args.output_file, "w") as output_file:
output_file.write(
process_gerber(
outline_file=outline,
solderpaste_file=solder_paste,
stencil_thickness=args.thickness,
include_ledge=args.include_ledge,
ledge_thickness=args.ledge_thickness,
gap=args.gap,
increase_hole_size_by=args.increase_hole_size,
flip_stencil=args.flip,
include_frame=False,
frame_width=0,
frame_height=0,
frame_thickness=1.2,
simplify_regions=False,
stencil_width=0,
stencil_height=0,
stencil_margin=0,
)
)