-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaltHinge.py
More file actions
148 lines (102 loc) · 4.68 KB
/
altHinge.py
File metadata and controls
148 lines (102 loc) · 4.68 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 16 11:03:09 2015
@author: Luimi
"""
import os
import sys
import re
from solid import *
from solid.utils import *
SEGMENTS = 48
'''
rough construction of a hinge. only paramater that can be controlled is the height of the hinge and the tolerance,
- radius of small cylinder is held constant at 1.5 mm
- thickness of the hinge is held constant at 6.0 mm
'''
def cutout(length):
# cut= cube(size=[5.0,10.5, 6.0], center=True)
#cut= cube(size=[5.0,9., 6.0], center=True)
cut= cube(size=[5.0,9.+1.5, 6.0], center=True)
cut = rotate(a=90, v=[0,1,0])(cut)
cut =rotate(a=90,v=[0,0,1])(cut)
edgeCut = cube(size=[length,3.,5.0],center = True)
# edgeCut = cube(size=[length,.5,5.0],center = True)
#edgeCut = translate([0,-1.5-.75,0])(edgeCut)
return cut+edgeCut
def hinge():
base = cube(size = [3.,2.,3.], center=True)
base += translate([0,0,-2.25])(cube(size=[3.,2,1.5],center=True))
male = cylinder(h=3,r1=1.5,r2=0.)
male = rotate(a=90,v=[180,1,0])(male)
male = translate([0,-1.,0])(male)
female = cube(size = [3.,3.,3.5],center=True)
female = translate([0,-3.,0])(female)
femaleCut = cylinder(h=3,r1=1.5+.35,r2=0.)
femaleCut = rotate(a=90,v=[180,1,0])(femaleCut)
femaleCut = translate([0,-1.,0])(femaleCut)
female-=femaleCut
topSupport = cube(size=[3.0,9.,2.], center=True)
topSupport = translate([0,0,1.+1.75 + 1.5])(topSupport)
connector = translate([0,-3.,3])(cube(size = [3.,3.,3.5],center=True))
bottomSupport= cube(size=[3.,9.,3.], center=True)
bottomSupport = translate([0,0,-1.5 -3.])(bottomSupport)
hinge= base+male + mirror([0,1,0])(male) + female + mirror([0,1,0])(female) + topSupport+ connector + mirror([0,1,0])(connector)+bottomSupport
hinge = rotate(a=90, v=[0,1,0])(hinge)
hinge =rotate(a=90,v=[0,0,1])(hinge)
return hinge
def hinge2():
base = cube(size = [3.,2.,3.], center=True)
base += translate([0,0,-2.25])(cube(size=[3.,2,1.5],center=True))
male = cylinder(h=3,r1=1.5,r2=0.)
male = rotate(a=90,v=[180,1,0])(male)
male = translate([0,-1.,0])(male)
female = cube(size = [3.,3.,3.5],center=True)
female = translate([0,-3.,0])(female)
femaleCut = cylinder(h=3,r1=1.5+.35,r2=0.)
femaleCut = rotate(a=90,v=[180,1,0])(femaleCut)
femaleCut = translate([0,-1.,0])(femaleCut)
female-=femaleCut
topSupport = cube(size=[3.0,9.,2.], center=True)
topSupport = translate([0,0,1.+1.75 + 1.5])(topSupport)
connector = translate([0,-3.,3])(cube(size = [3.,3.,3.5],center=True))
bottomSupport= cube(size=[3.,9.,3.], center=True)
bottomSupport = translate([0,0,-1.5 -3.])(bottomSupport)
hinge= base+male + mirror([0,1,0])(male) + female + mirror([0,1,0])(female)+ connector + mirror([0,1,0])(connector)
hinge = rotate(a=90, v=[0,1,0])(hinge)
hinge =rotate(a=90,v=[0,0,1])(hinge)
return hinge
def hingeDesign(radtol,ztol):
base = cube(size = [3.,2.,3.], center=True)
base += translate([0,0,-2.25])(cube(size=[3.,2,1.5],center=True))
male = cylinder(h=3,r1=1.5,r2=0.)
male = rotate(a=90,v=[180,1,0])(male)
male = translate([0,-1.,0])(male)
female = cube(size = [3.,3.,3.5],center=True)
female = translate([0,-3.,0])(female)
connector = translate([0,-3.,3])(cube(size = [3.,3.,3.5],center=True))
female+=connector
femaleCut = cylinder(h=3+ztol,r1=1.5+radtol,r2=0.)
femaleCut = rotate(a=90,v=[180,1,0])(femaleCut)
femaleCut = translate([0,-1.,0])(femaleCut)
female-=femaleCut
topSupport = cube(size=[3.0,9.,2.], center=True)
topSupport = translate([0,0,1.+1.75 + 1.5])(topSupport)
bottomSupport= cube(size=[3.,9.,3.], center=True)
bottomSupport = translate([0,0,-1.5 -3.])(bottomSupport)
hinge= base+male + mirror([0,1,0])(male) + female + mirror([0,1,0])(female) + topSupport+bottomSupport
hinge = rotate(a=90, v=[0,1,0])(hinge)
hinge =rotate(a=90,v=[0,0,1])(hinge)
return hinge
if __name__ == '__main__':
out_dir = sys.argv[1] if len(sys.argv) > 1 else os.curdir
file_out = os.path.join(out_dir, 'althinge.scad')
#a = hinge()
#a +=cutout(25)
a = hingeDesign(.4,.35)
print("%(__file__)s: SCAD file written to: \n%(file_out)s" % vars())
# Adding the file_header argument as shown allows you to change
# the detail of arcs by changing the SEGMENTS variable. This can
# be expensive when making lots of small curves, but is otherwise
# useful.
scad_render_to_file(a, file_out, file_header='$fn = %s;' % SEGMENTS)