-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbearing-flange.scad
269 lines (248 loc) · 10.5 KB
/
bearing-flange.scad
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
//
// FLANGE BEARING - USING 2 or 4 BOLTS
// by ISC 2021-09
//
// rough visual representation only
// accurate measurement/holes for product design
//
// profile = FlangeBearingProfile( ... ) - create profile
// FlangeBearing( profile ) - draw 3D
// FlangeBearingPanelHole( profile ) - draw 2D panel holes
//
include <KVTree.scad>
include <utility.scad>
//
// DEMO
//
// run me !!!
//FlangeBearing_Demo();
module FlangeBearing_Demo() {
profile2a = FlangeBearingProfile(
shaftDiameter = 8,
boltDistance = 37,
height = 12 );
PartAndPanel() {
FlangeBearing( profile2a );
FlangeBearingPanelHole( profile2a );
}
profile2b = FlangeBearingProfile(
shaftDiameter = 10,
boltDiameter = 5,
boltDistance = 80,
boltCount = 2,
height = 20,
width = 100,
depth = 60 );
translate( [150,0,0] )
PartAndPanel() {
FlangeBearing( profile2b );
FlangeBearingPanelHole( profile2b, enlargeBolt=3 );
}
profile4a = FlangeBearingProfile(
shaftDiameter = 8,
boltDistance = 37,
boltCount = 4,
height = 12 );
translate( [300,0,0] )
PartAndPanel() {
FlangeBearing( profile4a );
FlangeBearingPanelHole( profile4a, omitCenterHole=false, enlargeShaft=5 );
}
profile4b = FlangeBearingProfile(
shaftDiameter = 10,
boltDiameter = 5,
boltDistance = 50,
boltCount = 4,
height = 32,
ringHeight = 25,
baseHeight = 10,
width = 100,
depth = 80 );
translate( [450,0,0] )
PartAndPanel() {
FlangeBearing( profile4b );
FlangeBearingPanelHole( profile4b );
}
kvEchoAligned( profile4b );
module PartAndPanel() {
children(0);
translate( [0,-100,0] )
linear_extrude( 3 )
difference() {
square( [120,100], center=true );
children(1);
}
}
}
//
// CORE
//
function FlangeBearingProfile(
model = "",
shaftDiameter,
boltDistance, // bolt to bolt distance
boltCount = 2,
height,
boltDiameter = 5,
width = undef,
depth = undef,
ringHeight = undef,
baseHeight = undef
) = let (
e1=ErrorIf( shaftDiameter==undef, "shaft diameter missing" ),
e2=ErrorIf( boltDistance ==undef, "bolt distance missing" ),
e3=ErrorIf( boltCount!=2 && boltCount!=4, "invalid number of bolts [2|4]" ),
e4=ErrorIf( height == undef, "height missing" ),
eWidth = IIF( boltCount==2,
/* 2 bolts */ SELECT( width, boltDistance+boltDiameter*2.5 ),
/* 4 bolts */ SELECT( width, depth, boltDistance+boltDiameter*4 )
),
eDepth = IIF( boltCount==2,
/* 2 bolts */ SELECT( depth, boltDistance/2*1.5 ),
/* 4 bolts */ SELECT( depth, width, boltDistance+boltDiameter*4 )
),
eRingHeight = SELECT( ringHeight, height*0.6 ),
eBaseHeight = SELECT( baseHeight, height/3 )
) KVTree([
"type" , "flange bearing",
"model" , model,
"shaftDiameter", shaftDiameter,
"bolt" , KVTree([ "diameter", boltDiameter, "distance", boltDistance, "count", boltCount ]),
"width" , eWidth,
"depth" , eDepth,
"height" , KVTree([ "center", height, "ring", eRingHeight, "base", eBaseHeight ])
]);
module FlangeBearing( profile ) {
t = kvSearch(profile,"type");
e1=ErrorIf( t!="flange bearing", "FlangeBearing(): invalid profile" );
go();
module go() {
shaftDiameter = kvGet(profile, "shaftDiameter" );
boltDiameter = kvGet(profile, "bolt.diameter" );
boltToBolt = kvGet(profile, "bolt.distance" );
boltCount = kvGet(profile, "bolt.count" );
width = kvGet(profile, "width" );
depth = kvGet(profile, "depth" );
cenerHeight = kvGet(profile, "height.center" );
ringHeight = kvGet(profile, "height.ring" );
baseHeight = kvGet(profile, "height.base" );
if ( boltCount == 2 )
bolt2();
else
bolt4();
module bolt2() {
// |<- width->|
// _ ---
// __--/ \--__
// | o O o | depth
// --__ __--
// \ / ---
//
// +-+ ---
// | | mainHeight
// +-+-+-+ | ---
// | | | ringHeight
// +-+-----+-+ | | ---
// | | v v baseHeight
// +---------+ ------------
sideDiameters = width - boltToBolt;
centerToBolts = boltToBolt/2;
mainRing = shaftDiameter + (depth-shaftDiameter)/4;
outerRing = shaftDiameter + (depth-shaftDiameter)*0.9;
innerRing = shaftDiameter + (depth-shaftDiameter)*0.5;
difference() {
union() {
linear_extrude( baseHeight )
hull() {
circle( d=depth );
translate( [-centerToBolts,0,0] ) circle( d=sideDiameters );
translate( [ centerToBolts,0,0] ) circle( d=sideDiameters );
}
cylinder( cenerHeight, d=mainRing );
color( "gray" )
cylinder( ringHeight+0.1, d=innerRing );
}
union() {
translate([0,0,-1]) {
cylinder( cenerHeight+2, d=shaftDiameter );
translate( [ centerToBolts,0,0] ) cylinder( baseHeight+2, d=boltDiameter );
translate( [-centerToBolts,0,0] ) cylinder( baseHeight+2, d=boltDiameter );
}
}
}
difference() {
cylinder( ringHeight, d=outerRing );
translate( [0,0,-1] ) cylinder( ringHeight+2, d=innerRing );
}
}
module bolt4() {
minDim = min(width,depth);
cornerDiameters = minDim - boltToBolt;
b2b2 = boltToBolt/2;
mainRing = shaftDiameter + (minDim-shaftDiameter)/4;
outerRing = shaftDiameter + (minDim-shaftDiameter)*0.7;
innerRing = shaftDiameter + (minDim-shaftDiameter)*0.5;
wOff = (width-cornerDiameters)/2;
dOff = (depth-cornerDiameters)/2;
difference() {
union() {
linear_extrude( baseHeight )
if ( cornerDiameters>0 )
hull() {
//circle( d=depth );
translate( [ wOff, dOff,0] ) circle( d=cornerDiameters );
translate( [ wOff,-dOff,0] ) circle( d=cornerDiameters );
translate( [-wOff, dOff,0] ) circle( d=cornerDiameters );
translate( [-wOff,-dOff,0] ) circle( d=cornerDiameters );
}
else
square( [width,depth], center=true );
cylinder( cenerHeight, d=mainRing );
color( "gray" )
cylinder( ringHeight+0.1, d=innerRing );
}
union() {
translate([0,0,-1]) {
cylinder( cenerHeight+2, d=shaftDiameter );
translate( [ b2b2, b2b2,0] ) cylinder( baseHeight+2, d=boltDiameter );
translate( [ b2b2,-b2b2,0] ) cylinder( baseHeight+2, d=boltDiameter );
translate( [-b2b2, b2b2,0] ) cylinder( baseHeight+2, d=boltDiameter );
translate( [-b2b2,-b2b2,0] ) cylinder( baseHeight+2, d=boltDiameter );
}
}
}
difference() {
cylinder( ringHeight, d=outerRing );
translate( [0,0,-1] ) cylinder( ringHeight+2, d=innerRing );
}
}
}
}
module FlangeBearingPanelHole( profile, omitCenterHole=true, enlargeShaft=1, enlargeBolt=1 ) {
t = kvSearch(profile,"type");
e1=ErrorIf( t!="flange bearing", "FlangeBearingPanelHole(): invalid profile" );
boltCount = kvGet(profile, "bolt.count" );
if ( boltCount==2 ) bolt2(); else bolt4();
module bolt2() {
shaftDiameter = kvGet(profile, "shaftDiameter" );
boltDiameter = kvGet(profile, "bolt.diameter" );
boltToBolt = kvGet(profile, "bolt.distance" );
b2b2 = boltToBolt/2;
if ( !omitCenterHole )
circle( d=shaftDiameter+enlargeShaft );
translate( [ b2b2,0,0] ) circle( d=boltDiameter+enlargeBolt );
translate( [-b2b2,0,0] ) circle( d=boltDiameter+enlargeBolt );
}
module bolt4() {
shaftDiameter = kvGet(profile, "shaftDiameter" );
boltDiameter = kvGet(profile, "bolt.diameter" );
boltToBolt = kvGet(profile, "bolt.distance" );
b2b2 = boltToBolt/2;
if ( !omitCenterHole )
circle( d=shaftDiameter+enlargeShaft );
translate( [ b2b2, b2b2,0] ) circle( d=boltDiameter+enlargeBolt );
translate( [ b2b2,-b2b2,0] ) circle( d=boltDiameter+enlargeBolt );
translate( [-b2b2, b2b2,0] ) circle( d=boltDiameter+enlargeBolt );
translate( [-b2b2,-b2b2,0] ) circle( d=boltDiameter+enlargeBolt );
}
}