rubyscad 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.gitignore +21 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/Rakefile +1 -0
  5. data/examples/BasicCube.rb +50 -0
  6. data/examples/ChamferCube.rb +96 -0
  7. data/examples/FilletCube.rb +317 -0
  8. data/examples/example001.rb +33 -0
  9. data/examples/example001.scad +11 -0
  10. data/examples/example002.rb +23 -0
  11. data/examples/example002.scad +18 -0
  12. data/examples/example003.rb +19 -0
  13. data/examples/example003.scad +15 -0
  14. data/examples/example004.rb +11 -0
  15. data/examples/example004.scad +6 -0
  16. data/examples/example005.rb +22 -0
  17. data/examples/example005.scad +31 -0
  18. data/examples/example006.rb +46 -0
  19. data/examples/example006.scad +221 -0
  20. data/examples/example007.dxf +2410 -0
  21. data/examples/example007.rb +53 -0
  22. data/examples/example007.scad +30 -0
  23. data/examples/example008.dxf +3238 -0
  24. data/examples/example008.rb +34 -0
  25. data/examples/example008.scad +26 -0
  26. data/examples/example009.dxf +3894 -0
  27. data/examples/example009.rb +33 -0
  28. data/examples/example009.scad +15 -0
  29. data/examples/example010.dat +51 -0
  30. data/examples/example010.rb +12 -0
  31. data/examples/example010.scad +7 -0
  32. data/examples/example011.rb +22 -0
  33. data/examples/example011.scad +3 -0
  34. data/examples/example012.rb +16 -0
  35. data/examples/example012.scad +8 -0
  36. data/examples/example012.stl +450 -0
  37. data/examples/example013.dxf +2276 -0
  38. data/examples/example013.rb +16 -0
  39. data/examples/example013.scad +12 -0
  40. data/examples/example014.rb +14 -0
  41. data/examples/example014.scad +12 -0
  42. data/examples/example015.rb +33 -0
  43. data/examples/example015.scad +22 -0
  44. data/examples/example016.rb +43 -0
  45. data/examples/example016.scad +49 -0
  46. data/examples/example016.stl +0 -0
  47. data/examples/example017.rb +170 -0
  48. data/examples/example017.scad +124 -0
  49. data/examples/example018.rb +29 -0
  50. data/examples/example018.scad +74 -0
  51. data/examples/example019.rb +22 -0
  52. data/examples/example019.scad +84 -0
  53. data/examples/example020.rb +92 -0
  54. data/examples/example020.scad +62 -0
  55. data/examples/example021.rb +42 -0
  56. data/examples/example021.scad +159 -0
  57. data/examples/example022.rb +44 -0
  58. data/examples/example022.scad +103 -0
  59. data/lib/{RubyScad.rb → rubyscad/RubyScad.rb} +0 -0
  60. data/lib/rubyscad/version.rb +1 -1
  61. data/lib/rubyscad.rb +1 -1
  62. data/rubyscad.gemspec +20 -0
  63. metadata +66 -7
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+ *~
15
+ Gemfile.lock
16
+ doc/
17
+
18
+ # YARD artifacts
19
+ .yardoc
20
+ _yardoc
21
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubyscad_bundle.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 cjbissonnette
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,50 @@
1
+ require 'rubyscad'
2
+
3
+ class BasicCube
4
+ include RubyScad
5
+
6
+ attr_accessor :size, :center
7
+
8
+ def initialize(args={})
9
+ @size = args.fetch(:size, [1,1,1])
10
+ @center = args.fetch(:center, true)
11
+ end
12
+
13
+ def x()
14
+ @size[0]
15
+ end
16
+
17
+ def x=(value)
18
+ @size[0] = value
19
+ end
20
+
21
+ def y()
22
+ @size[1]
23
+ end
24
+
25
+ def y=(value)
26
+ @size[1] = value
27
+ end
28
+
29
+ def z()
30
+ @size[2]
31
+ end
32
+
33
+ def z=(value)
34
+ @size[2] = value
35
+ end
36
+
37
+ def translate_centered(&block)
38
+ unless @center
39
+ translate(v:[x/2.0, y/2.0, z/2.0], &block)
40
+ else
41
+ yield
42
+ end
43
+ end
44
+
45
+ def render(args={})
46
+ translate_centered {
47
+ cube(size:@size, center: true)
48
+ }
49
+ end
50
+ end
@@ -0,0 +1,96 @@
1
+ load 'BasicCube.rb'
2
+
3
+ class ChamferCube < BasicCube
4
+
5
+ def initialize(args={})
6
+ super
7
+ @chamfer = [].fill(0, 0..11)
8
+ end
9
+
10
+ def chamfer_edge(edge, value)
11
+ @chamfer[edge] = value
12
+ end
13
+
14
+ def chamfer_edges(array)
15
+ array.each { |v| chamfer_edge(v[0], v[1]) }
16
+ end
17
+
18
+ def chamfer_side(side, value)
19
+ case side
20
+ when 0
21
+ chamfer_edge(0, value)
22
+ chamfer_edge(1, value)
23
+ chamfer_edge(2, value)
24
+ chamfer_edge(3, value)
25
+ when 1
26
+ chamfer_edge(0, value)
27
+ chamfer_edge(4, value)
28
+ chamfer_edge(5, value)
29
+ chamfer_edge(8, value)
30
+ when 2
31
+ chamfer_edge(5, value)
32
+ chamfer_edge(1, value)
33
+ chamfer_edge(6, value)
34
+ chamfer_edge(9, value)
35
+ when 3
36
+ chamfer_edge(2, value)
37
+ chamfer_edge(6, value)
38
+ chamfer_edge(7, value)
39
+ chamfer_edge(10, value)
40
+ when 4
41
+ chamfer_edge(3, value)
42
+ chamfer_edge(4, value)
43
+ chamfer_edge(11, value)
44
+ chamfer_edge(7, value)
45
+ when 5
46
+ chamfer_edge(8, value)
47
+ chamfer_edge(9, value)
48
+ chamfer_edge(10, value)
49
+ chamfer_edge(11, value)
50
+ end
51
+ end
52
+
53
+ def chamfer_sides(array)
54
+ array.each{ |v| chamfer_side(v[0], v[1]) }
55
+ end
56
+
57
+ def apply_chamfer(edge, value)
58
+ case edge
59
+ when 0
60
+ translate(y: -y/2.0, z: z/2.0) { rotate(x:45) { chamfer_cube([x+PAD, value, value]) } }
61
+ when 1
62
+ translate(x: x/2.0, y: -y/2.0) { rotate(z:45) { chamfer_cube([value, value, z+PAD]) } }
63
+ when 2
64
+ translate(y: -y/2.0, z: -z/2.0) { rotate(x:45) { chamfer_cube([x+PAD, value, value]) } }
65
+ when 3
66
+ translate(x: -x/2.0, y: -y/2.0) { rotate(z:45) { chamfer_cube([value, value, z+PAD]) } }
67
+ when 4
68
+ translate(x: -x/2.0, z: z/2.0) { rotate(y:45) { chamfer_cube([value, y+PAD, value]) } }
69
+ when 5
70
+ translate(x: x/2.0, z: z/2.0) { rotate(y:45) { chamfer_cube([value, y+PAD, value]) } }
71
+ when 6
72
+ translate(x: x/2.0, z: -z/2.0) { rotate(y:45) { chamfer_cube([value, y+PAD, value]) } }
73
+ when 7
74
+ translate(x: -x/2.0, z: -z/2.0) { rotate(y:45) { chamfer_cube([value, y+PAD, value]) } }
75
+ when 8
76
+ translate(y: y/2.0, z: z/2.0) { rotate(x:45) { chamfer_cube([x+PAD, value, value]) } }
77
+ when 9
78
+ translate(x: x/2.0, y: y/2.0) { rotate(z:45) { chamfer_cube([value, value, z+PAD]) } }
79
+ when 10
80
+ translate(y: y/2.0, z: -z/2.0) { rotate(x:45) { chamfer_cube([x+PAD, value, value]) } }
81
+ when 11
82
+ translate(x: -x/2.0, y: y/2.0) { rotate(z:45) { chamfer_cube([value, value, z+PAD]) } }
83
+ end
84
+ end
85
+
86
+ def chamfer_cube(size)
87
+ cube(size: size, center: true)
88
+ end
89
+
90
+ def render(args={})
91
+ difference {
92
+ super
93
+ @chamfer.each_with_index { |v, i| apply_chamfer(i, v) if v > 0 }
94
+ }
95
+ end
96
+ end
@@ -0,0 +1,317 @@
1
+ load "ChamferCube.rb"
2
+
3
+ class FilletCube < ChamferCube
4
+
5
+ attr_accessor :smooth
6
+
7
+ def initialize(args={})
8
+ super
9
+ @smooth = 30
10
+ @fillet = [].fill(0, 0..11)
11
+ end
12
+
13
+ def fillet_edge(edge, value)
14
+ @fillet[edge] = value
15
+ end
16
+
17
+ def fillet_edges(array)
18
+ array.each { |v| fillet_edge(v[0], v[1]) }
19
+ end
20
+
21
+ def fillet_side(side, value)
22
+ case side
23
+ when 0
24
+ fillet_edge(0, value)
25
+ fillet_edge(1, value)
26
+ fillet_edge(2, value)
27
+ fillet_edge(3, value)
28
+ when 1
29
+ fillet_edge(0, value)
30
+ fillet_edge(4, value)
31
+ fillet_edge(5, value)
32
+ fillet_edge(8, value)
33
+ when 2
34
+ fillet_edge(5, value)
35
+ fillet_edge(1, value)
36
+ fillet_edge(6, value)
37
+ fillet_edge(9, value)
38
+ when 3
39
+ fillet_edge(2, value)
40
+ fillet_edge(6, value)
41
+ fillet_edge(7, value)
42
+ fillet_edge(10, value)
43
+ when 4
44
+ fillet_edge(3, value)
45
+ fillet_edge(4, value)
46
+ fillet_edge(11, value)
47
+ fillet_edge(7, value)
48
+ when 5
49
+ fillet_edge(8, value)
50
+ fillet_edge(9, value)
51
+ fillet_edge(10, value)
52
+ fillet_edge(11, value)
53
+ end
54
+ end
55
+
56
+ def fillet_sides(array)
57
+ array.each{ |v| fillet_side(v[0], v[1]) }
58
+ end
59
+
60
+ def apply_fillet(edge, value)
61
+ case edge
62
+ when 0
63
+ translate(y: -y/2.0+value, z: z/2.0-value) {
64
+ difference() {
65
+ translate(y:-value-PAD, z: value+PAD) {
66
+ fillet_cube([x+2.0*PAD, value*2.0+PAD, value*2.0+PAD])
67
+ }
68
+ rotate(y: 90) { fillet_cylinder(x+4*PAD, value) }
69
+ }
70
+ }
71
+ when 1
72
+ translate(x: x/2.0-value, y: -y/2.0+value) {
73
+ difference() {
74
+ translate(x: value+PAD, y: -value-PAD) {
75
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, z+2.0*PAD])
76
+ }
77
+ fillet_cylinder(z+4*PAD,value)
78
+ }
79
+ }
80
+ when 2
81
+ translate(y: -y/2.0+value, z: -z/2.0+value) {
82
+ difference() {
83
+ translate(y: -value-PAD, z: -value-PAD) {
84
+ fillet_cube([x+2.0*PAD, value*2.0+PAD, value*2.0+PAD])
85
+ }
86
+ rotate(y: 90) { fillet_cylinder(x+4*PAD,value) }
87
+ }
88
+ }
89
+ when 3
90
+ translate(x: -x/2.0+value, y: -y/2.0+value) {
91
+ difference() {
92
+ translate(x: -value-PAD, y: -value-PAD) {
93
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, z+2.0*PAD])
94
+ }
95
+ fillet_cylinder(z+4*PAD,value)
96
+ }
97
+ }
98
+ when 4
99
+ translate(x: -x/2.0+value, z: z/2.0-value) {
100
+ difference() {
101
+ translate(x: -value-PAD, z: value+PAD) {
102
+ fillet_cube([value*2.0+PAD, y+2.0*PAD, value*2.0+PAD])
103
+ }
104
+ rotate(y: 90, z: 90) { fillet_cylinder(y+4*PAD, value) }
105
+ }
106
+ }
107
+ when 5
108
+ translate(x: x/2.0-value, z: z/2.0-value) {
109
+ difference() {
110
+ translate(x: value+PAD, z: value+PAD) {
111
+ fillet_cube([value*2.0+PAD, y+2.0*PAD, value*2.0+PAD])
112
+ }
113
+ rotate(y: 90, z: 90) { fillet_cylinder(y+4*PAD, value) }
114
+ }
115
+ }
116
+ when 6
117
+ translate(x: x/2.0-value, z: -z/2.0+value) {
118
+ difference() {
119
+ translate(x: value+PAD, z: -value-PAD) {
120
+ fillet_cube([value*2.0+PAD, y+2.0*PAD, value*2.0+PAD])
121
+ }
122
+ rotate(y: 90, z: 90) { fillet_cylinder(y+4*PAD, value) }
123
+ }
124
+ }
125
+ when 7
126
+ translate(x: -x/2.0+value, z: -z/2.0+value) {
127
+ difference() {
128
+ translate(x: -value-PAD, z: -value-PAD) {
129
+ fillet_cube([value*2.0+PAD, y+2.0*PAD, value*2.0+PAD])
130
+ }
131
+ rotate(y: 90, z: 90) { fillet_cylinder(y+4*PAD, value) }
132
+ }
133
+ }
134
+ when 8
135
+ translate(y: y/2.0-value, z: z/2.0-value) {
136
+ difference() {
137
+ translate(y: value+PAD, z: value+PAD) {
138
+ fillet_cube([x+2.0*PAD, value*2.0+PAD, value*2.0+PAD])
139
+ }
140
+ rotate(x: 90) { fillet_cylinder(x+4*PAD,value) }
141
+ }
142
+ }
143
+ when 9
144
+ translate(x: x/2.0-value, y: y/2.0-value) {
145
+ difference() {
146
+ translate(x: value+PAD, y: value+PAD) {
147
+ fillet_cube([value*2+PAD, value*2+PAD, z+2*PAD])
148
+ }
149
+ fillet_cylinder(z+4*PAD, value)
150
+ }
151
+ }
152
+ when 10
153
+ translate(y: y/2.0-value, z: -z/2.0+value) {
154
+ difference() {
155
+ translate(y: value+PAD, z: -value-PAD) {
156
+ fillet_cube([x+2.0*PAD, value*2.0+PAD, value*2.0+PAD])
157
+ }
158
+ rotate(x: 90) { fillet_cylinder(x+4*PAD,value) }
159
+ }
160
+ }
161
+ when 11
162
+ translate(x: -x/2.0+value, y: y/2.0-value) {
163
+ difference() {
164
+ translate(x: -value-PAD, y: value+PAD) {
165
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, z+2.0*PAD])
166
+ }
167
+ fillet_cylinder(z+4*PAD, value)
168
+ }
169
+ }
170
+ end
171
+ end
172
+
173
+ def fillet_corner(corner, value)
174
+ case corner
175
+ when 0
176
+ translate(v:[-x/2.0+value, -y/2.0+value, z/2.0-value]) {
177
+ difference() {
178
+ translate(v:[-value-PAD, -value-PAD, value+PAD]) {
179
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, value*2.0+PAD])
180
+ }
181
+ fillet_sphere(value)
182
+ }
183
+ }
184
+ when 1
185
+ translate(v:[x/2.0-value, -y/2.0+value, z/2.0-value]) {
186
+ difference() {
187
+ translate(v:[value+PAD, -value-PAD, value+PAD]) {
188
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, value*2.0+PAD])
189
+ }
190
+ fillet_sphere(value)
191
+ }
192
+ }
193
+ when 2
194
+ translate(v:[x/2.0-value, -y/2.0+value, -z/2.0+value]) {
195
+ difference() {
196
+ translate(v:[value+PAD, -value-PAD, -value-PAD]) {
197
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, value*2.0+PAD])
198
+ }
199
+ fillet_sphere(value)
200
+ }
201
+ }
202
+ when 3
203
+ translate(v:[-x/2.0+value, -y/2.0+value, -z/2.0+value]) {
204
+ difference() {
205
+ translate(v:[-value-PAD, -value-PAD, -value-PAD]) {
206
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, value*2.0+PAD])
207
+ }
208
+ fillet_sphere(value)
209
+ }
210
+ }
211
+ when 4
212
+ translate(v:[-x/2.0+value, y/2.0-value, z/2.0-value]) {
213
+ difference() {
214
+ translate(v:[-value-PAD, value+PAD, value+PAD]) {
215
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, value*2.0+PAD])
216
+ }
217
+ fillet_sphere(value)
218
+ }
219
+ }
220
+ when 5
221
+ translate(v:[x/2.0-value, y/2.0-value, z/2.0-value]) {
222
+ difference() {
223
+ translate(v: [value+PAD, value+PAD, value+PAD]) {
224
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, value*2.0+PAD])
225
+ }
226
+ fillet_sphere(value)
227
+ }
228
+ }
229
+ when 6
230
+ translate(v:[x/2.0-value, y/2.0-value, -z/2.0+value]) {
231
+ difference() {
232
+ translate(v:[value+PAD, value+PAD, -value-PAD]) {
233
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, value*2.0+PAD])
234
+ }
235
+ fillet_sphere(value)
236
+ }
237
+ }
238
+ when 7
239
+ translate(v:[-x/2.0+value, y/2.0-value, -z/2.0+value]) {
240
+ difference() {
241
+ translate(v:[-value-PAD, value+PAD, -value-PAD]) {
242
+ fillet_cube([value*2.0+PAD, value*2.0+PAD, value*2.0+PAD])
243
+ }
244
+ fillet_sphere(value)
245
+ }
246
+ }
247
+ end
248
+ end
249
+
250
+ def fillet_sphere(r)
251
+ sphere(r: r, fn: @smooth)
252
+ end
253
+
254
+ def fillet_cylinder(height, radius)
255
+ cylinder(r: radius, h: height, center: true, fn: @smooth)
256
+ end
257
+
258
+ def fillet_cube(size)
259
+ cube(size: size, center:true)
260
+ end
261
+
262
+ def greater_than_0(*args)
263
+ args.each { |v| return nil if v <= 0 }
264
+ return true
265
+ end
266
+
267
+ def auto_corner_fillet()
268
+ if greater_than_0(@fillet[0], @fillet[3], @fillet[4])
269
+ fillet = average(@fillet[0], @fillet[3], @fillet[4])
270
+ fillet_corner(0, fillet)
271
+ end
272
+ if greater_than_0(@fillet[0], @fillet[1], @fillet[5])
273
+ fillet = average(@fillet[0], @fillet[1], @fillet[5])
274
+ fillet_corner(1, fillet)
275
+ end
276
+ if greater_than_0(@fillet[1], @fillet[2], @fillet[6])
277
+ fillet = average(@fillet[1], @fillet[2], @fillet[6])
278
+ fillet_corner(2, fillet)
279
+ end
280
+ if greater_than_0(@fillet[2], @fillet[3], @fillet[7])
281
+ fillet = average(@fillet[2], @fillet[3], @fillet[7])
282
+ fillet_corner(3, fillet)
283
+ end
284
+ if greater_than_0(@fillet[4], @fillet[8], @fillet[11])
285
+ fillet = average(@fillet[4], @fillet[8], @fillet[11])
286
+ fillet_corner(4, fillet)
287
+ end
288
+ if greater_than_0(@fillet[5], @fillet[8], @fillet[9])
289
+ fillet = average(@fillet[5], @fillet[8], @fillet[9])
290
+ fillet_corner(5, fillet)
291
+ end
292
+ if greater_than_0(@fillet[6], @fillet[9], @fillet[10])
293
+ fillet = average(@fillet[6], @fillet[9], @fillet[10])
294
+ fillet_corner(6, fillet)
295
+ end
296
+ if greater_than_0(@fillet[7], @fillet[10], @fillet[11])
297
+ fillet = average(@fillet[7], @fillet[10], @fillet[11])
298
+ fillet_corner(7, fillet)
299
+ end
300
+ end
301
+
302
+ def average(*args)
303
+ args.inject(0.0) { |sum, el| sum + el } / args.size
304
+ end
305
+
306
+ def render(args={})
307
+ difference {
308
+ super
309
+ @fillet.each_with_index { |v, i| apply_fillet(i, v) if v > 0 }
310
+ auto_corner_fillet()
311
+ }
312
+ end
313
+ end
314
+
315
+ #cube = FilletCube.new(size:[5, 7, 8], center: true)
316
+ #cube.fillet_sides([[0,1], [1,1], [2,1], [3,1], [4,1], [5,1]])
317
+ #cube.render
@@ -0,0 +1,33 @@
1
+ require 'rubyscad'
2
+
3
+ class Example001
4
+ include RubyScad
5
+
6
+ def initialize(args={})
7
+ @size = args.fetch(:size, 50).to_f
8
+ @hole = args.fetch(:hole, 25).to_f
9
+ end
10
+
11
+ def r_from_dia(d)
12
+ d / 2.0
13
+ end
14
+
15
+ def rotcy(rot, r, h)
16
+ rotate(a: 90, v: rot)
17
+ cylinder(r: r, h: h, center: true)
18
+ end
19
+
20
+ def render
21
+ cy_r = r_from_dia(@hole)
22
+ cy_h = r_from_dia(@size * 2.5)
23
+
24
+ difference() {
25
+ sphere(r: r_from_dia(@size))
26
+ rotcy([0, 0, 0], cy_r, cy_h)
27
+ rotcy([1, 0, 0], cy_r, cy_h)
28
+ rotcy([0, 1, 0], cy_r, cy_h)
29
+ }
30
+ end
31
+ end
32
+
33
+ Example001.new(size: ARGV.fetch(0, 50), hole: ARGV.fetch(1, 25)).render if __FILE__ == $0
@@ -0,0 +1,11 @@
1
+ //created with rubyscad 1.0
2
+
3
+ difference() {
4
+ sphere(r = 25.000);
5
+ rotate(a = 90, v = [0, 0, 0])
6
+ cylinder(r = 12.500, h = 62.500, center = true);
7
+ rotate(a = 90, v = [1, 0, 0])
8
+ cylinder(r = 12.500, h = 62.500, center = true);
9
+ rotate(a = 90, v = [0, 1, 0])
10
+ cylinder(r = 12.500, h = 62.500, center = true);
11
+ }
@@ -0,0 +1,23 @@
1
+ require 'rubyscad'
2
+
3
+ module Example002
4
+ extend RubyScad
5
+
6
+ intersection() {
7
+ difference() {
8
+ union() {
9
+ cube(size: 30, center: true)
10
+ translate(z:-25)
11
+ cube(size: [15, 15, 50], center: true)
12
+ }
13
+ union() {
14
+ cube(size: [50, 10, 10], center: true)
15
+ cube(size: [10, 50, 10], center: true)
16
+ cube(size: [10, 10, 50], center: true)
17
+ }
18
+ }
19
+ translate(z: 5)
20
+ cylinder(h: 50, r1: 20, r2: 5, center: true)
21
+ }
22
+ end
23
+
@@ -0,0 +1,18 @@
1
+ //created with rubyscad 1.0
2
+
3
+ intersection() {
4
+ difference() {
5
+ union() {
6
+ cube(size = 30, center = true);
7
+ translate(v = [0.000, 0.000, -25])
8
+ cube(size = [15, 15, 50], center = true);
9
+ }
10
+ union() {
11
+ cube(size = [50, 10, 10], center = true);
12
+ cube(size = [10, 50, 10], center = true);
13
+ cube(size = [10, 10, 50], center = true);
14
+ }
15
+ }
16
+ translate(v = [0.000, 0.000, 5])
17
+ cylinder(h = 50, r1 = 20, r2 = 5, center = true);
18
+ }
@@ -0,0 +1,19 @@
1
+ require 'rubyscad'
2
+
3
+ module Example003
4
+ extend RubyScad
5
+
6
+ difference() {
7
+ union() {
8
+ cube(size: 30, center: true)
9
+ cube(size: [40, 15, 15], center: true)
10
+ cube(size: [15, 40, 15], center: true)
11
+ cube(size: [15, 15, 40], center: true)
12
+ }
13
+ union() {
14
+ cube(size: [50, 10, 10], center: true)
15
+ cube(size: [10, 50, 10], center: true)
16
+ cube(size: [10, 10, 50], center: true)
17
+ }
18
+ }
19
+ end
@@ -0,0 +1,15 @@
1
+ //created with rubyscad 1.0
2
+
3
+ difference() {
4
+ union() {
5
+ cube(size = 30, center = true);
6
+ cube(size = [40, 15, 15], center = true);
7
+ cube(size = [15, 40, 15], center = true);
8
+ cube(size = [15, 15, 40], center = true);
9
+ }
10
+ union() {
11
+ cube(size = [50, 10, 10], center = true);
12
+ cube(size = [10, 50, 10], center = true);
13
+ cube(size = [10, 10, 50], center = true);
14
+ }
15
+ }
@@ -0,0 +1,11 @@
1
+ require "rubyscad"
2
+
3
+ module Example004
4
+ extend RubyScad
5
+
6
+ difference() {
7
+ cube(size: 30, center: true)
8
+ sphere(r: 20)
9
+ }
10
+ end
11
+
@@ -0,0 +1,6 @@
1
+ //created with rubyscad 1.0
2
+
3
+ difference() {
4
+ cube(size = 30, center = true);
5
+ sphere(r = 20);
6
+ }
@@ -0,0 +1,22 @@
1
+ require "rubyscad"
2
+
3
+ module Example005
4
+ extend RubyScad
5
+
6
+ translate(z: -120) {
7
+ difference() {
8
+ cylinder(h: 50, r: 100)
9
+ translate(z: 10); cylinder(h: 50, r: 80)
10
+ translate(v: [100, 0, 35]); cube(size: 50, center: true)
11
+ }
12
+
13
+ (0..5).each do |i|
14
+ echo(360*i/6, Math.sin((360*i/6).radians)*80, Math.cos((360*i/6).radians)*80)
15
+ translate(v:[Math.sin((360*i/6).radians)*80, Math.cos((360*i/6).radians)*80, 0])
16
+ cylinder(h: 200, r: 10)
17
+ end
18
+
19
+ translate(z: 200)
20
+ cylinder(h: 80, r1: 120, r2: 0)
21
+ }
22
+ end