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
@@ -0,0 +1,16 @@
1
+ require "rubyscad"
2
+
3
+ module Example013
4
+ extend RubyScad
5
+
6
+ intersection() {
7
+ linear_extrude(height: 100, center: true, convexity: 3)
8
+ import(file: "example013.dxf");
9
+ rotate(a: [0, 90, 0])
10
+ linear_extrude(height: 100, center: true, convexity: 3)
11
+ import(file: "example013.dxf");
12
+ rotate(a: [90, 0, 0])
13
+ linear_extrude(height: 100, center: true, convexity: 3)
14
+ import(file: "example013.dxf");
15
+ }
16
+ end
@@ -0,0 +1,12 @@
1
+ //created with rubyscad 1.0
2
+
3
+ intersection() {
4
+ linear_extrude(height = 100, center = true, convexity = 3)
5
+ import(file = "example013.dxf");
6
+ rotate(a = [0, 90, 0])
7
+ linear_extrude(height = 100, center = true, convexity = 3)
8
+ import(file = "example013.dxf");
9
+ rotate(a = [90, 0, 0])
10
+ linear_extrude(height = 100, center = true, convexity = 3)
11
+ import(file = "example013.dxf");
12
+ }
@@ -0,0 +1,14 @@
1
+ require "rubyscad"
2
+
3
+ module Example014
4
+ extend RubyScad
5
+
6
+ intersection() {
7
+ [[0, 0, 0],
8
+ [10, 20, 300],
9
+ [200, 40, 57],
10
+ [20, 88, 57]
11
+ ].each { |i| rotate(a: i); cube(size: [100, 20, 20], center: true) }
12
+ }
13
+ end
14
+
@@ -0,0 +1,12 @@
1
+ //created with rubyscad 1.0
2
+
3
+ intersection() {
4
+ rotate(a = [0, 0, 0])
5
+ cube(size = [100, 20, 20], center = true);
6
+ rotate(a = [10, 20, 300])
7
+ cube(size = [100, 20, 20], center = true);
8
+ rotate(a = [200, 40, 57])
9
+ cube(size = [100, 20, 20], center = true);
10
+ rotate(a = [20, 88, 57])
11
+ cube(size = [100, 20, 20], center = true);
12
+ }
@@ -0,0 +1,33 @@
1
+ require "rubyscad"
2
+
3
+ module Example015
4
+ extend RubyScad
5
+
6
+ def self.shape()
7
+ difference() {
8
+ translate(v: [ -35, -35 ])
9
+ intersection() {
10
+ union() {
11
+ difference() {
12
+ square(size: 100, center: true);
13
+ square(size: 50, center: true);
14
+ }
15
+ translate(v: [ 50, 50 ])
16
+ square(size: 15, center: true);
17
+ }
18
+ rotate(a: 45); translate(v: [ 0, -15 ]); square(size: [ 100, 30 ])
19
+ }
20
+ rotate(a: -45); scale(v: [ 0.7, 1.3 ]); circle(r: 5)
21
+ }
22
+ import(file: "example009.dxf",
23
+ layer: "body",
24
+ convexity: 6,
25
+ scale: 2)
26
+ end
27
+
28
+ #linear_extrude(convexity: 10, center: true)
29
+ shape();
30
+ end
31
+
32
+
33
+
@@ -0,0 +1,22 @@
1
+ //created with rubyscad 1.0
2
+
3
+ difference() {
4
+ translate(v = [-35, -35])
5
+ intersection() {
6
+ union() {
7
+ difference() {
8
+ square(size = 100, center = true);
9
+ square(size = 50, center = true);
10
+ }
11
+ translate(v = [50, 50])
12
+ square(size = 15, center = true);
13
+ }
14
+ rotate(a = 45)
15
+ translate(v = [0, -15])
16
+ square(size = [100, 30]);
17
+ }
18
+ rotate(a = -45)
19
+ scale(v = [0.700, 1.300])
20
+ circle(r = 5);
21
+ }
22
+ import(file = "example009.dxf", layer = "body", convexity = 6, scale = 2);
@@ -0,0 +1,43 @@
1
+ require "rubyscad"
2
+
3
+ # example016.stl is derived from Mblock.stl
4
+ # (c) 2009 Will Langford licensed under
5
+ # the Creative Commons - GNU GPL license.
6
+ # http://www.thingiverse.com/thing:753
7
+
8
+ # Jonas Pfeil converted the file to binary
9
+ # STL and duplicated its content.
10
+
11
+ module Example0016
12
+ extend RubyScad
13
+
14
+ def self.blk1()
15
+ cube(size: [ 65, 28, 28 ], center: true)
16
+ end
17
+
18
+ def self.blk2()
19
+ difference() {
20
+ translate(z: 7.5)
21
+ cube(size: [ 60, 28, 14 ], center: true)
22
+ cube(size: [ 8, 32, 32 ], center: true)
23
+ }
24
+ end
25
+
26
+ def self.chop()
27
+ translate(x: -14)
28
+ import(file: "example016.stl", convexity: 12)
29
+ end
30
+
31
+ difference() {
32
+ blk1()
33
+ [0, 90, 180, 270].each do |alpha|
34
+ rotate(a: alpha, v: [ 1, 0, 0])
35
+ render(convexity: 12)
36
+ difference() {
37
+ blk2()
38
+ chop()
39
+ }
40
+ end
41
+ }
42
+ end
43
+
@@ -0,0 +1,49 @@
1
+ //created with rubyscad 1.0
2
+
3
+ difference() {
4
+ cube(size = [65, 28, 28], center = true);
5
+ rotate(a = 0, v = [1, 0, 0])
6
+ render(convexity = 12)
7
+ difference() {
8
+ difference() {
9
+ translate(v = [0, 0, 7.500])
10
+ cube(size = [60, 28, 14], center = true);
11
+ cube(size = [8, 32, 32], center = true);
12
+ }
13
+ translate(v = [-14, 0])
14
+ import(file = "example016.stl", convexity = 12);
15
+ }
16
+ rotate(a = 90, v = [1, 0, 0])
17
+ render(convexity = 12)
18
+ difference() {
19
+ difference() {
20
+ translate(v = [0, 0, 7.500])
21
+ cube(size = [60, 28, 14], center = true);
22
+ cube(size = [8, 32, 32], center = true);
23
+ }
24
+ translate(v = [-14, 0])
25
+ import(file = "example016.stl", convexity = 12);
26
+ }
27
+ rotate(a = 180, v = [1, 0, 0])
28
+ render(convexity = 12)
29
+ difference() {
30
+ difference() {
31
+ translate(v = [0, 0, 7.500])
32
+ cube(size = [60, 28, 14], center = true);
33
+ cube(size = [8, 32, 32], center = true);
34
+ }
35
+ translate(v = [-14, 0])
36
+ import(file = "example016.stl", convexity = 12);
37
+ }
38
+ rotate(a = 270, v = [1, 0, 0])
39
+ render(convexity = 12)
40
+ difference() {
41
+ difference() {
42
+ translate(v = [0, 0, 7.500])
43
+ cube(size = [60, 28, 14], center = true);
44
+ cube(size = [8, 32, 32], center = true);
45
+ }
46
+ translate(v = [-14, 0])
47
+ import(file = "example016.stl", convexity = 12);
48
+ }
49
+ }
Binary file
@@ -0,0 +1,170 @@
1
+ require "rubyscad"
2
+
3
+ class Example017
4
+ include RubyScad
5
+
6
+ def initialize(args={})
7
+ #:parts, :exploded, :assembled
8
+ @mode = args.fetch(:mode, "parts")
9
+
10
+ @thickness = 6.0
11
+ @locklen1 = 15.0
12
+ @locklen2 = 10.0
13
+ @boltlen = 15.0
14
+ @midhole = 10.0
15
+ @inner1_to_inner2 = 50.0
16
+ @total_height = 80.0
17
+ end
18
+
19
+ def shape_tripod()
20
+ x1 = 0
21
+ x2 = x1 + @thickness
22
+ x3 = x2 + @locklen1
23
+ x4 = x3 + @thickness
24
+ x5 = x4 + @inner1_to_inner2
25
+ x6 = x5 - @thickness
26
+ x7 = x6 - @locklen2
27
+ x8 = x7 - @thickness
28
+ x9 = x8 - @thickness
29
+ x10 = x9 - @thickness
30
+
31
+ y1 = 0
32
+ y2 = y1 + @thickness
33
+ y3 = y2 + @thickness
34
+ y4 = y3 + @thickness
35
+ y5 = y3 + @total_height - 3*@thickness
36
+ y6 = y5 + @thickness
37
+
38
+ union() {
39
+ difference() {
40
+ polygon(points:
41
+ [
42
+ [ x1, y2 ], [ x2, y2 ],
43
+ [ x2, y1 ], [ x3, y1 ], [ x3, y2 ],
44
+ [ x4, y2 ], [ x4, y1 ], [ x5, y1 ],
45
+ [ x5 + @thickness, y3 ], [ x5, y4 ],
46
+ [ x5, y5 ],
47
+ [ x6, y5 ], [ x6, y6 ], [ x7, y6 ], [ x7, y5 ], [ x8, y5 ],
48
+ [ x8, y6 ], [ x9, y5 ],
49
+ [ x9, y4 ], [ x10, y3 ],
50
+ [ x2, y3 ]
51
+ ])
52
+ translate(v: [ x10, y4 ]); circle(r: @thickness)
53
+ translate(v: [ x5 + @thickness, y4 ]); circle(r: @thickness)
54
+ }
55
+
56
+ translate(v: [ x5, y1 ])
57
+ square(size: [ @boltlen - @thickness, @thickness*2 ])
58
+
59
+ translate(v: [ x5 + @boltlen - @thickness, y2 ]); circle(r:@thickness)
60
+
61
+ translate(v: [ x2, y2 ])
62
+ intersection() {
63
+ circle(r: @thickness);
64
+ translate(v: [ -@thickness*2, 0 ]); square(size: @thickness*2)
65
+ }
66
+
67
+ translate(v: [ x8, y5 ])
68
+ intersection() {
69
+ circle(r: @thickness);
70
+ translate(v: [ -@thickness*2, 0 ]); square(size: @thickness*2)
71
+ }
72
+ }
73
+ end
74
+
75
+ def shape_inner_disc()
76
+ difference() {
77
+ circle(r: @midhole + @boltlen + 2*@thickness + @locklen2);
78
+ [ 0, 120, 240 ].each do |alpha|
79
+ rotate(a: alpha)
80
+ translate(v: [ 0, @midhole + @boltlen + @thickness + @locklen2/2 ])
81
+ square(size: [ @thickness, @locklen2 ], center: true)
82
+ circle(r: @midhole + @boltlen)
83
+ end
84
+ }
85
+ end
86
+
87
+ def shape_outer_disc()
88
+ difference() {
89
+ circle(r: @midhole + @boltlen + @inner1_to_inner2 + 2*@thickness + @locklen1)
90
+ [ 0, 120, 240 ].each do |alpha|
91
+ rotate(a: alpha)
92
+ translate(v: [ 0, @midhole + @boltlen + @inner1_to_inner2 + @thickness + @locklen1/2 ])
93
+ square(size: [ @thickness, @locklen1 ], center: true)
94
+ circle(r: @midhole + @boltlen + @inner1_to_inner2)
95
+ end
96
+ }
97
+ end
98
+
99
+ def parts()
100
+ tripod_x_off = @locklen1 - @locklen2 + @inner1_to_inner2
101
+ tripod_y_off = [@midhole + @boltlen + @inner1_to_inner2 + 4*@thickness + @locklen1, @total_height].max
102
+ shape_inner_disc()
103
+ shape_outer_disc()
104
+
105
+ [ [1,1], [-1,1], [1,-1] ].each do |s|
106
+ scale(v: s); translate(v: [ tripod_x_off, -tripod_y_off ]); shape_tripod()
107
+ end
108
+ end
109
+
110
+ def exploded()
111
+ translate(v: [ 0, 0, @total_height + 2*@thickness ])
112
+ linear_extrude(height: @thickness, convexity: 4)
113
+ shape_inner_disc()
114
+ linear_extrude(height: @thickness, convexity: 4); shape_outer_disc()
115
+
116
+ color(c: [ 0.7, 0.7, 1 ]) {
117
+ [ 0, 120, 240 ].each do |alpha|
118
+ rotate(a: alpha)
119
+ translate(v: [ 0, @thickness*2 + @locklen1 + @inner1_to_inner2 + @boltlen + @midhole, 1.5*@thickness ])
120
+ rotate(a: [ 90, 0, -90 ])
121
+ linear_extrude(height: @thickness, convexity: 10, center: true); shape_tripod()
122
+ end
123
+ }
124
+ end
125
+
126
+ def bottle()
127
+ r = @boltlen + @midhole;
128
+ h = @total_height - @thickness*2;
129
+
130
+ rotate_extrude(convexity: 2) {
131
+ square(size: [ r, h ])
132
+
133
+ translate(v: [ 0, h ])
134
+ intersection() {
135
+ square(size: [ r, r ]);
136
+ scale(v: [ 1, 0.7 ]); circle(r: r)
137
+ }
138
+
139
+ translate(v: [ 0, h+r ])
140
+ intersection() {
141
+ translate(v: [ 0, -r/2 ]); square(size: [ r/2, r ])
142
+ circle(r: r/2);
143
+ }
144
+ }
145
+ end
146
+
147
+ def assembled()
148
+ translate(z: @total_height - @thickness)
149
+ linear_extrude(height: @thickness, convexity: 4); shape_inner_disc()
150
+ linear_extrude(height: @thickness, convexity: 4); shape_outer_disc()
151
+
152
+ color(color: [ 0.7, 0.7, 1 ]) {
153
+ [ 0, 120, 240 ].each do |alpha|
154
+ rotate(a: alpha)
155
+ translate(y: @thickness*2 + @locklen1 + @inner1_to_inner2 + @boltlen + @midhole)
156
+ rotate(a: [ 90, 0, -90 ])
157
+ linear_extrude(height: @thickness, convexity: 10, center: true); shape_tripod()
158
+ end
159
+ }
160
+ background; translate(z: @thickness*2); bottle()
161
+ end
162
+
163
+ def render()
164
+ parts() if (@mode == :parts)
165
+ exploded() if (@mode == :exploded)
166
+ assembled() if (@mode == :assembled)
167
+ end
168
+ end
169
+
170
+ Example017.new(mode: :exploded).render()
@@ -0,0 +1,124 @@
1
+ //created with rubyscad 1.0
2
+
3
+ translate(v = [0, 0, 92.000])
4
+ linear_extrude(height = 6.000, convexity = 4)
5
+ difference() {
6
+ circle(r = 47.000);
7
+ rotate(a = 0)
8
+ translate(v = [0, 36.000])
9
+ square(size = [6.000, 10.000], center = true);
10
+ circle(r = 25.000);
11
+ rotate(a = 120)
12
+ translate(v = [0, 36.000])
13
+ square(size = [6.000, 10.000], center = true);
14
+ circle(r = 25.000);
15
+ rotate(a = 240)
16
+ translate(v = [0, 36.000])
17
+ square(size = [6.000, 10.000], center = true);
18
+ circle(r = 25.000);
19
+ }
20
+ linear_extrude(height = 6.000, convexity = 4)
21
+ difference() {
22
+ circle(r = 102.000);
23
+ rotate(a = 0)
24
+ translate(v = [0, 88.500])
25
+ square(size = [6.000, 15.000], center = true);
26
+ circle(r = 75.000);
27
+ rotate(a = 120)
28
+ translate(v = [0, 88.500])
29
+ square(size = [6.000, 15.000], center = true);
30
+ circle(r = 75.000);
31
+ rotate(a = 240)
32
+ translate(v = [0, 88.500])
33
+ square(size = [6.000, 15.000], center = true);
34
+ circle(r = 75.000);
35
+ }
36
+ color(c = [0.700, 0.700, 1], color = [0, 0, 0, 1]) {
37
+ rotate(a = 0)
38
+ translate(v = [0, 102.000, 9.000])
39
+ rotate(a = [90, 0, -90])
40
+ linear_extrude(height = 6.000, convexity = 10, center = true)
41
+ union() {
42
+ difference() {
43
+ polygon(points = [[0, 6.000], [6.000, 6.000], [6.000, 0], [21.000, 0], [21.000, 6.000], [27.000, 6.000], [27.000, 0], [77.000, 0], [83.000, 12.000], [77.000, 18.000], [77.000, 74.000], [71.000, 74.000], [71.000, 80.000], [61.000, 80.000], [61.000, 74.000], [55.000, 74.000], [55.000, 80.000], [49.000, 74.000], [49.000, 18.000], [43.000, 12.000], [6.000, 12.000]]);
44
+ translate(v = [43.000, 18.000])
45
+ circle(r = 6.000);
46
+ translate(v = [83.000, 18.000])
47
+ circle(r = 6.000);
48
+ }
49
+ translate(v = [77.000, 0])
50
+ square(size = [9.000, 12.000]);
51
+ translate(v = [86.000, 6.000])
52
+ circle(r = 6.000);
53
+ translate(v = [6.000, 6.000])
54
+ intersection() {
55
+ circle(r = 6.000);
56
+ translate(v = [-12.000, 0])
57
+ square(size = 12.000);
58
+ }
59
+ translate(v = [55.000, 74.000])
60
+ intersection() {
61
+ circle(r = 6.000);
62
+ translate(v = [-12.000, 0])
63
+ square(size = 12.000);
64
+ }
65
+ }
66
+ rotate(a = 120)
67
+ translate(v = [0, 102.000, 9.000])
68
+ rotate(a = [90, 0, -90])
69
+ linear_extrude(height = 6.000, convexity = 10, center = true)
70
+ union() {
71
+ difference() {
72
+ polygon(points = [[0, 6.000], [6.000, 6.000], [6.000, 0], [21.000, 0], [21.000, 6.000], [27.000, 6.000], [27.000, 0], [77.000, 0], [83.000, 12.000], [77.000, 18.000], [77.000, 74.000], [71.000, 74.000], [71.000, 80.000], [61.000, 80.000], [61.000, 74.000], [55.000, 74.000], [55.000, 80.000], [49.000, 74.000], [49.000, 18.000], [43.000, 12.000], [6.000, 12.000]]);
73
+ translate(v = [43.000, 18.000])
74
+ circle(r = 6.000);
75
+ translate(v = [83.000, 18.000])
76
+ circle(r = 6.000);
77
+ }
78
+ translate(v = [77.000, 0])
79
+ square(size = [9.000, 12.000]);
80
+ translate(v = [86.000, 6.000])
81
+ circle(r = 6.000);
82
+ translate(v = [6.000, 6.000])
83
+ intersection() {
84
+ circle(r = 6.000);
85
+ translate(v = [-12.000, 0])
86
+ square(size = 12.000);
87
+ }
88
+ translate(v = [55.000, 74.000])
89
+ intersection() {
90
+ circle(r = 6.000);
91
+ translate(v = [-12.000, 0])
92
+ square(size = 12.000);
93
+ }
94
+ }
95
+ rotate(a = 240)
96
+ translate(v = [0, 102.000, 9.000])
97
+ rotate(a = [90, 0, -90])
98
+ linear_extrude(height = 6.000, convexity = 10, center = true)
99
+ union() {
100
+ difference() {
101
+ polygon(points = [[0, 6.000], [6.000, 6.000], [6.000, 0], [21.000, 0], [21.000, 6.000], [27.000, 6.000], [27.000, 0], [77.000, 0], [83.000, 12.000], [77.000, 18.000], [77.000, 74.000], [71.000, 74.000], [71.000, 80.000], [61.000, 80.000], [61.000, 74.000], [55.000, 74.000], [55.000, 80.000], [49.000, 74.000], [49.000, 18.000], [43.000, 12.000], [6.000, 12.000]]);
102
+ translate(v = [43.000, 18.000])
103
+ circle(r = 6.000);
104
+ translate(v = [83.000, 18.000])
105
+ circle(r = 6.000);
106
+ }
107
+ translate(v = [77.000, 0])
108
+ square(size = [9.000, 12.000]);
109
+ translate(v = [86.000, 6.000])
110
+ circle(r = 6.000);
111
+ translate(v = [6.000, 6.000])
112
+ intersection() {
113
+ circle(r = 6.000);
114
+ translate(v = [-12.000, 0])
115
+ square(size = 12.000);
116
+ }
117
+ translate(v = [55.000, 74.000])
118
+ intersection() {
119
+ circle(r = 6.000);
120
+ translate(v = [-12.000, 0])
121
+ square(size = 12.000);
122
+ }
123
+ }
124
+ }
@@ -0,0 +1,29 @@
1
+ require "rubyscad"
2
+
3
+ module Example018
4
+ extend RubyScad
5
+
6
+ def self.step(len, mod, *objects)
7
+ (0..objects.length-1).each do |i|
8
+ translate(x: len*(i - (objects.length-1)/2))
9
+ objects[(i+mod) % objects.length].call
10
+ end
11
+ end
12
+
13
+ (1..4).each do |i|
14
+ translate(y: -250+i*100) {
15
+ step(100, i,
16
+ proc {sphere(r: 30)},
17
+ proc {cube(size: 60, center: true)},
18
+ proc { cylinder(r: 30, h: 50, center: true)},
19
+ proc {
20
+ union() {
21
+ cube(size: 45, center: true);
22
+ rotate(a: [45, 0, 0]); cube(size: 50, center: true);
23
+ rotate(a: [0, 45, 0]); cube(size: 50, center: true);
24
+ rotate(a: [0, 0, 45]); cube(size: 50, center: true);
25
+ }
26
+ })
27
+ }
28
+ end
29
+ end
@@ -0,0 +1,74 @@
1
+ //created with rubyscad 1.0
2
+
3
+ translate(v = [0, -150]) {
4
+ translate(v = [-100, 0])
5
+ cube(size = 60, center = true);
6
+ translate(v = [0, 0])
7
+ cylinder(r = 30, h = 50, center = true);
8
+ translate(v = [100, 0])
9
+ union() {
10
+ cube(size = 45, center = true);
11
+ rotate(a = [45, 0, 0])
12
+ cube(size = 50, center = true);
13
+ rotate(a = [0, 45, 0])
14
+ cube(size = 50, center = true);
15
+ rotate(a = [0, 0, 45])
16
+ cube(size = 50, center = true);
17
+ }
18
+ translate(v = [200, 0])
19
+ sphere(r = 30);
20
+ }
21
+ translate(v = [0, -50]) {
22
+ translate(v = [-100, 0])
23
+ cylinder(r = 30, h = 50, center = true);
24
+ translate(v = [0, 0])
25
+ union() {
26
+ cube(size = 45, center = true);
27
+ rotate(a = [45, 0, 0])
28
+ cube(size = 50, center = true);
29
+ rotate(a = [0, 45, 0])
30
+ cube(size = 50, center = true);
31
+ rotate(a = [0, 0, 45])
32
+ cube(size = 50, center = true);
33
+ }
34
+ translate(v = [100, 0])
35
+ sphere(r = 30);
36
+ translate(v = [200, 0])
37
+ cube(size = 60, center = true);
38
+ }
39
+ translate(v = [0, 50]) {
40
+ translate(v = [-100, 0])
41
+ union() {
42
+ cube(size = 45, center = true);
43
+ rotate(a = [45, 0, 0])
44
+ cube(size = 50, center = true);
45
+ rotate(a = [0, 45, 0])
46
+ cube(size = 50, center = true);
47
+ rotate(a = [0, 0, 45])
48
+ cube(size = 50, center = true);
49
+ }
50
+ translate(v = [0, 0])
51
+ sphere(r = 30);
52
+ translate(v = [100, 0])
53
+ cube(size = 60, center = true);
54
+ translate(v = [200, 0])
55
+ cylinder(r = 30, h = 50, center = true);
56
+ }
57
+ translate(v = [0, 150]) {
58
+ translate(v = [-100, 0])
59
+ sphere(r = 30);
60
+ translate(v = [0, 0])
61
+ cube(size = 60, center = true);
62
+ translate(v = [100, 0])
63
+ cylinder(r = 30, h = 50, center = true);
64
+ translate(v = [200, 0])
65
+ union() {
66
+ cube(size = 45, center = true);
67
+ rotate(a = [45, 0, 0])
68
+ cube(size = 50, center = true);
69
+ rotate(a = [0, 45, 0])
70
+ cube(size = 50, center = true);
71
+ rotate(a = [0, 0, 45])
72
+ cube(size = 50, center = true);
73
+ }
74
+ }
@@ -0,0 +1,22 @@
1
+ require "rubyscad"
2
+
3
+ module Example019
4
+ extend RubyScad
5
+
6
+ def self.get_cylinder_h(p)
7
+ lookup(p, {
8
+ -200=>5,
9
+ -50=>20,
10
+ -20=>18,
11
+ 80=>25,
12
+ 150=>2
13
+ })
14
+ end
15
+
16
+ (-100..100).step(5) do |i|
17
+ #echo(i, get_cylinder_h(i));
18
+ translate(v: [ i, 0, -30 ])
19
+ cylinder(r1: 6, r2: 2, h: get_cylinder_h(i)*3)
20
+ end
21
+ end
22
+