-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathassembly.py
74 lines (67 loc) · 1.71 KB
/
assembly.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
"""
Display the drawers
"""
import cadquery as cq
import importlib
import base
import organiser_collets
import organiser_3_125_bits
importlib.reload(base)
importlib.reload(organiser_collets)
importlib.reload(organiser_3_125_bits)
sep = 20 # seperation between parts
big_sep = 100 # extra for the organisers
assy = cq.Assembly()
assy.add(base.frame, name="frame")
assy.add(base.drawer, name="drawer")
assy.add(organiser_collets.collet_organiser, name="collet organiser")
assy.add(organiser_3_125_bits.bit_organiser, name="bit organiser")
# pull the drawer out
assy.constrain(
"frame",
base.frame.faces("<Y").val().translate((0, -sep, 0)),
"drawer",
base.drawer.faces(">Y").val(),
"Point",
)
# bit organiser aligns with back face of drawer and is big_sep above
assy.constrain(
"drawer",
base.drawer.faces("<Y[1]").val().translate((0, 0, big_sep)),
"bit organiser",
organiser_3_125_bits.bit_organiser.faces(">Y").val(),
"Point",
)
assy.constrain(
"bit organiser",
organiser_3_125_bits.bit_organiser.faces("<Y").val().translate((0, -sep, 0)),
"collet organiser",
organiser_collets.collet_organiser.faces(">Y").val(),
"Point",
)
# align the z and x axes between obj0 and obj1
align_these = (
("frame", "drawer"),
("drawer", "collet organiser"),
("drawer", "bit organiser"),
)
for obj0, obj1 in align_these:
assy.constrain(
obj0,
cq.Face.makePlane(),
obj1,
cq.Face.makePlane(),
"Axis",
0,
)
assy.constrain(
obj0,
cq.Face.makePlane(dir=(1, 0, 0)),
obj1,
cq.Face.makePlane(dir=(1, 0, 0)),
"Axis",
0,
)
assy.solve()
if "show_object" in locals():
show_object(assy)