rubyscad 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/Rakefile +1 -0
- data/examples/BasicCube.rb +50 -0
- data/examples/ChamferCube.rb +96 -0
- data/examples/FilletCube.rb +317 -0
- data/examples/example001.rb +33 -0
- data/examples/example001.scad +11 -0
- data/examples/example002.rb +23 -0
- data/examples/example002.scad +18 -0
- data/examples/example003.rb +19 -0
- data/examples/example003.scad +15 -0
- data/examples/example004.rb +11 -0
- data/examples/example004.scad +6 -0
- data/examples/example005.rb +22 -0
- data/examples/example005.scad +31 -0
- data/examples/example006.rb +46 -0
- data/examples/example006.scad +221 -0
- data/examples/example007.dxf +2410 -0
- data/examples/example007.rb +53 -0
- data/examples/example007.scad +30 -0
- data/examples/example008.dxf +3238 -0
- data/examples/example008.rb +34 -0
- data/examples/example008.scad +26 -0
- data/examples/example009.dxf +3894 -0
- data/examples/example009.rb +33 -0
- data/examples/example009.scad +15 -0
- data/examples/example010.dat +51 -0
- data/examples/example010.rb +12 -0
- data/examples/example010.scad +7 -0
- data/examples/example011.rb +22 -0
- data/examples/example011.scad +3 -0
- data/examples/example012.rb +16 -0
- data/examples/example012.scad +8 -0
- data/examples/example012.stl +450 -0
- data/examples/example013.dxf +2276 -0
- data/examples/example013.rb +16 -0
- data/examples/example013.scad +12 -0
- data/examples/example014.rb +14 -0
- data/examples/example014.scad +12 -0
- data/examples/example015.rb +33 -0
- data/examples/example015.scad +22 -0
- data/examples/example016.rb +43 -0
- data/examples/example016.scad +49 -0
- data/examples/example016.stl +0 -0
- data/examples/example017.rb +170 -0
- data/examples/example017.scad +124 -0
- data/examples/example018.rb +29 -0
- data/examples/example018.scad +74 -0
- data/examples/example019.rb +22 -0
- data/examples/example019.scad +84 -0
- data/examples/example020.rb +92 -0
- data/examples/example020.scad +62 -0
- data/examples/example021.rb +42 -0
- data/examples/example021.scad +159 -0
- data/examples/example022.rb +44 -0
- data/examples/example022.scad +103 -0
- data/lib/{RubyScad.rb → rubyscad/RubyScad.rb} +0 -0
- data/lib/rubyscad/version.rb +1 -1
- data/lib/rubyscad.rb +1 -1
- data/rubyscad.gemspec +20 -0
- metadata +66 -7
@@ -0,0 +1,84 @@
|
|
1
|
+
//created with rubyscad 1.0
|
2
|
+
|
3
|
+
translate(v = [-100, 0, -30])
|
4
|
+
cylinder(r1 = 6, r2 = 2, h = 45);
|
5
|
+
translate(v = [-95, 0, -30])
|
6
|
+
cylinder(r1 = 6, r2 = 2, h = 45);
|
7
|
+
translate(v = [-90, 0, -30])
|
8
|
+
cylinder(r1 = 6, r2 = 2, h = 48);
|
9
|
+
translate(v = [-85, 0, -30])
|
10
|
+
cylinder(r1 = 6, r2 = 2, h = 48);
|
11
|
+
translate(v = [-80, 0, -30])
|
12
|
+
cylinder(r1 = 6, r2 = 2, h = 51);
|
13
|
+
translate(v = [-75, 0, -30])
|
14
|
+
cylinder(r1 = 6, r2 = 2, h = 51);
|
15
|
+
translate(v = [-70, 0, -30])
|
16
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
17
|
+
translate(v = [-65, 0, -30])
|
18
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
19
|
+
translate(v = [-60, 0, -30])
|
20
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
21
|
+
translate(v = [-55, 0, -30])
|
22
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
23
|
+
translate(v = [-50, 0, -30])
|
24
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
25
|
+
translate(v = [-45, 0, -30])
|
26
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
27
|
+
translate(v = [-40, 0, -30])
|
28
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
29
|
+
translate(v = [-35, 0, -30])
|
30
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
31
|
+
translate(v = [-30, 0, -30])
|
32
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
33
|
+
translate(v = [-25, 0, -30])
|
34
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
35
|
+
translate(v = [-20, 0, -30])
|
36
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
37
|
+
translate(v = [-15, 0, -30])
|
38
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
39
|
+
translate(v = [-10, 0, -30])
|
40
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
41
|
+
translate(v = [-5, 0, -30])
|
42
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
43
|
+
translate(v = [0, 0, -30])
|
44
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
45
|
+
translate(v = [5, 0, -30])
|
46
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
47
|
+
translate(v = [10, 0, -30])
|
48
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
49
|
+
translate(v = [15, 0, -30])
|
50
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
51
|
+
translate(v = [20, 0, -30])
|
52
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
53
|
+
translate(v = [25, 0, -30])
|
54
|
+
cylinder(r1 = 6, r2 = 2, h = 63);
|
55
|
+
translate(v = [30, 0, -30])
|
56
|
+
cylinder(r1 = 6, r2 = 2, h = 63);
|
57
|
+
translate(v = [35, 0, -30])
|
58
|
+
cylinder(r1 = 6, r2 = 2, h = 63);
|
59
|
+
translate(v = [40, 0, -30])
|
60
|
+
cylinder(r1 = 6, r2 = 2, h = 66);
|
61
|
+
translate(v = [45, 0, -30])
|
62
|
+
cylinder(r1 = 6, r2 = 2, h = 66);
|
63
|
+
translate(v = [50, 0, -30])
|
64
|
+
cylinder(r1 = 6, r2 = 2, h = 66);
|
65
|
+
translate(v = [55, 0, -30])
|
66
|
+
cylinder(r1 = 6, r2 = 2, h = 69);
|
67
|
+
translate(v = [60, 0, -30])
|
68
|
+
cylinder(r1 = 6, r2 = 2, h = 69);
|
69
|
+
translate(v = [65, 0, -30])
|
70
|
+
cylinder(r1 = 6, r2 = 2, h = 69);
|
71
|
+
translate(v = [70, 0, -30])
|
72
|
+
cylinder(r1 = 6, r2 = 2, h = 72);
|
73
|
+
translate(v = [75, 0, -30])
|
74
|
+
cylinder(r1 = 6, r2 = 2, h = 72);
|
75
|
+
translate(v = [80, 0, -30])
|
76
|
+
cylinder(r1 = 6, r2 = 2, h = 75);
|
77
|
+
translate(v = [85, 0, -30])
|
78
|
+
cylinder(r1 = 6, r2 = 2, h = 69);
|
79
|
+
translate(v = [90, 0, -30])
|
80
|
+
cylinder(r1 = 6, r2 = 2, h = 63);
|
81
|
+
translate(v = [95, 0, -30])
|
82
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
83
|
+
translate(v = [100, 0, -30])
|
84
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require "rubyscad"
|
2
|
+
|
3
|
+
module Example020
|
4
|
+
extend RubyScad
|
5
|
+
extend Math
|
6
|
+
|
7
|
+
def self.screw(type = 2, r1 = 15, r2 = 20, n = 7, h = 100, t = 8)
|
8
|
+
linear_extrude(height: h, twist: 360*t/n, convexity: t)
|
9
|
+
difference() {
|
10
|
+
circle(r: r2)
|
11
|
+
(0..n-1).each do |i|
|
12
|
+
if (type == 1)
|
13
|
+
rotate(a: i*360/n)
|
14
|
+
polygon(points: [
|
15
|
+
[ 2*r2, 0 ],
|
16
|
+
[ r2, 0 ],
|
17
|
+
[ r1*cos((180/n).radians), r1*sin((180/n).radians) ],
|
18
|
+
[ r2*cos((360/n).radians), r2*sin((360/n).radians) ],
|
19
|
+
[ 2*r2*cos((360/n).radians), 2*r2*sin((360/n).radians) ],
|
20
|
+
])
|
21
|
+
elsif (type == 2)
|
22
|
+
rotate(a: i*360/n)
|
23
|
+
polygon(points: [
|
24
|
+
[ 2*r2, 0 ],
|
25
|
+
[ r2, 0 ],
|
26
|
+
[ r1*cos((90/n).radians), r1*sin((90/n).radians) ],
|
27
|
+
[ r1*cos((180/n).radians), r1*sin((180/n).radians) ],
|
28
|
+
[ r2*cos((270/n).radians), r2*sin((270/n).radians) ],
|
29
|
+
[ 2*r2*cos((270/n).radians), 2*r2*sin((270/n).radians) ],
|
30
|
+
])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.nut(type = 2, r1 = 16, r2 = 21, r3 = 30, s = 6, n = 7, h = 100/5, t = 8/5)
|
37
|
+
difference() {
|
38
|
+
cylinder(fn: s, r: r3, h: h)
|
39
|
+
translate(v: [ 0, 0, -h/2 ]); screw(type, r1, r2, n, h*2, t*2)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.spring(r1 = 100.0, r2 = 10.0, h = 100.0, hr = 12.0)
|
44
|
+
stepsize = 1.0/16.0
|
45
|
+
|
46
|
+
segment = lambda do |i1, i2|
|
47
|
+
alpha1 = i1 * 360*r2/hr
|
48
|
+
alpha2 = i2 * 360*r2/hr
|
49
|
+
len1 = sin(acos((i1*2-1).radians))*r2
|
50
|
+
len2 = sin(acos((i2*2-1).radians))*r2
|
51
|
+
if (len1 < 0.01)
|
52
|
+
polygon(points: [
|
53
|
+
[ cos(alpha1.radians)*r1, sin(alpha1.radians)*r1 ],
|
54
|
+
[ cos(alpha2.radians)*(r1-len2), sin(alpha2.radians)*(r1-len2) ],
|
55
|
+
[ cos(alpha2.radians)*(r1+len2), sin(alpha2.radians)*(r1+len2) ]
|
56
|
+
])
|
57
|
+
end
|
58
|
+
if (len2 < 0.01)
|
59
|
+
polygon(points: [
|
60
|
+
[ cos(alpha1.radians)*(r1+len1), sin(alpha1.radians)*(r1+len1) ],
|
61
|
+
[ cos(alpha1.radians)*(r1-len1), sin(alpha1.radians)*(r1-len1) ],
|
62
|
+
[ cos(alpha2.radians)*r1, sin(alpha2.radians)*r1 ],
|
63
|
+
])
|
64
|
+
end
|
65
|
+
if (len1 >= 0.01 && len2 >= 0.01)
|
66
|
+
polygon(points: [
|
67
|
+
[ cos(alpha1.radians)*(r1+len1), sin(alpha1.radians)*(r1+len1) ],
|
68
|
+
[ cos(alpha1.radians)*(r1-len1), sin(alpha1.radians)*(r1-len1) ],
|
69
|
+
[ cos(alpha2.radians)*(r1-len2), sin(alpha2.radians)*(r1-len2) ],
|
70
|
+
[ cos(alpha2.radians)*(r1+len2), sin(alpha2.radians)*(r1+len2) ]
|
71
|
+
])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
linear_extrude(height: 100, twist: 180*h/hr, fn: (hr/r2)/stepsize, convexity: 5) {
|
76
|
+
(stepsize..1+stepsize/2).step(stepsize).each do |i|
|
77
|
+
segment.call(i-stepsize, [i, 1].min)
|
78
|
+
end
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
translate(x: -30)
|
84
|
+
screw()
|
85
|
+
|
86
|
+
translate(x: 30)
|
87
|
+
nut()
|
88
|
+
|
89
|
+
spring()
|
90
|
+
end
|
91
|
+
|
92
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
//created with rubyscad 1.0
|
2
|
+
|
3
|
+
translate(v = [-30, 0])
|
4
|
+
linear_extrude(height = 100, twist = 411, convexity = 8)
|
5
|
+
difference() {
|
6
|
+
circle(r = 20);
|
7
|
+
rotate(a = 0)
|
8
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
9
|
+
rotate(a = 51)
|
10
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
11
|
+
rotate(a = 102)
|
12
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
13
|
+
rotate(a = 154)
|
14
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
15
|
+
rotate(a = 205)
|
16
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
17
|
+
rotate(a = 257)
|
18
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
19
|
+
rotate(a = 308)
|
20
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
21
|
+
}
|
22
|
+
translate(v = [30, 0])
|
23
|
+
difference() {
|
24
|
+
cylinder($fn = 6, r = 30, h = 20);
|
25
|
+
translate(v = [0, 0, -10])
|
26
|
+
linear_extrude(height = 40, twist = 102, convexity = 2)
|
27
|
+
difference() {
|
28
|
+
circle(r = 21);
|
29
|
+
rotate(a = 0)
|
30
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
31
|
+
rotate(a = 51)
|
32
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
33
|
+
rotate(a = 102)
|
34
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
35
|
+
rotate(a = 154)
|
36
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
37
|
+
rotate(a = 205)
|
38
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
39
|
+
rotate(a = 257)
|
40
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
41
|
+
rotate(a = 308)
|
42
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
linear_extrude(height = 100, twist = 1500.000, $fn = 19.200, convexity = 5) {
|
46
|
+
polygon(points = [[109.998, 0.000], [90.002, 0.000], [85.225, 28.930], [104.161, 35.358]]);
|
47
|
+
polygon(points = [[104.161, 35.358], [85.225, 28.930], [71.402, 54.789], [87.268, 66.963]]);
|
48
|
+
polygon(points = [[87.268, 66.963], [71.402, 54.789], [50.002, 74.833], [61.112, 91.461]]);
|
49
|
+
polygon(points = [[61.112, 91.461], [50.002, 74.833], [23.294, 86.934], [28.470, 106.251]]);
|
50
|
+
polygon(points = [[28.470, 106.251], [23.294, 86.934], [-5.886, 89.808], [-7.194, 109.764]]);
|
51
|
+
polygon(points = [[-7.194, 109.764], [-5.886, 89.808], [-34.442, 83.149], [-42.095, 101.627]]);
|
52
|
+
polygon(points = [[-42.095, 101.627], [-34.442, 83.149], [-59.341, 67.666], [-72.528, 82.702]]);
|
53
|
+
polygon(points = [[-72.528, 82.702], [-59.341, 67.666], [-77.942, 45.000], [-95.263, 55.000]]);
|
54
|
+
polygon(points = [[-95.263, 55.000], [-77.942, 45.000], [-88.271, 17.558], [-107.886, 21.460]]);
|
55
|
+
polygon(points = [[-107.886, 21.460], [-88.271, 17.558], [-89.230, -11.747], [-109.059, -14.358]]);
|
56
|
+
polygon(points = [[-109.059, -14.358], [-89.230, -11.747], [-80.719, -39.806], [-98.656, -48.652]]);
|
57
|
+
polygon(points = [[-98.656, -48.652], [-80.719, -39.806], [-63.640, -63.640], [-77.781, -77.781]]);
|
58
|
+
polygon(points = [[-77.781, -77.781], [-63.640, -63.640], [-39.806, -80.719], [-48.651, -98.655]]);
|
59
|
+
polygon(points = [[-48.651, -98.655], [-39.806, -80.719], [-11.747, -89.231], [-14.358, -109.058]]);
|
60
|
+
polygon(points = [[-14.358, -109.058], [-11.747, -89.231], [17.558, -88.272], [21.460, -107.885]]);
|
61
|
+
polygon(points = [[21.460, -107.885], [17.558, -88.272], [45.001, -77.944], [54.999, -95.261]]);
|
62
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "rubyscad"
|
2
|
+
|
3
|
+
module Example021
|
4
|
+
extend RubyScad
|
5
|
+
|
6
|
+
fa 30
|
7
|
+
|
8
|
+
def self.thing()
|
9
|
+
|
10
|
+
difference() {
|
11
|
+
sphere(r: 25)
|
12
|
+
cylinder(h: 62.5, r1: 12.5, r2: 6.25, center: true)
|
13
|
+
rotate(x: 90)
|
14
|
+
cylinder(h: 62.5, r1: 12.5, r2: 6.25, center: true)
|
15
|
+
rotate(y: 90)
|
16
|
+
cylinder(h: 62.5, r1: 12.5, r2: 6.25, center: true)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.demo_proj()
|
21
|
+
linear_extrude(center: true, height: 0.5)
|
22
|
+
projection(cut: false)
|
23
|
+
thing()
|
24
|
+
background; thing()
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.demo_cut()
|
28
|
+
(-20..+20).step(5) do |i|
|
29
|
+
rotate(a: -30, v:[ 1, 1, 0 ]); translate(z: -i)
|
30
|
+
linear_extrude(center: true, height: 0.5); projection(cut: true)
|
31
|
+
translate(z: i); rotate(a: 30, v: [ 1, 1, 0 ]); thing()
|
32
|
+
end
|
33
|
+
background; thing()
|
34
|
+
end
|
35
|
+
|
36
|
+
translate(x: -30) {
|
37
|
+
demo_proj()
|
38
|
+
}
|
39
|
+
translate(x: 30) {
|
40
|
+
demo_cut()
|
41
|
+
}
|
42
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
//created with rubyscad 1.0
|
2
|
+
|
3
|
+
$fa = 30;
|
4
|
+
translate(v = [-30, 0]) {
|
5
|
+
linear_extrude(center = true, height = 0.500)
|
6
|
+
projection(cut = false)
|
7
|
+
difference() {
|
8
|
+
sphere(r = 25);
|
9
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
10
|
+
rotate(a = [90, 0])
|
11
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
12
|
+
rotate(a = [0, 90])
|
13
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
14
|
+
}
|
15
|
+
%difference() {
|
16
|
+
sphere(r = 25);
|
17
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
18
|
+
rotate(a = [90, 0])
|
19
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
20
|
+
rotate(a = [0, 90])
|
21
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
translate(v = [30, 0]) {
|
25
|
+
rotate(a = -30, v = [1, 1, 0])
|
26
|
+
translate(v = [0, 0, 20])
|
27
|
+
linear_extrude(center = true, height = 0.500)
|
28
|
+
projection(cut = true)
|
29
|
+
translate(v = [0, 0, -20])
|
30
|
+
rotate(a = 30, v = [1, 1, 0])
|
31
|
+
difference() {
|
32
|
+
sphere(r = 25);
|
33
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
34
|
+
rotate(a = [90, 0])
|
35
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
36
|
+
rotate(a = [0, 90])
|
37
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
38
|
+
}
|
39
|
+
rotate(a = -30, v = [1, 1, 0])
|
40
|
+
translate(v = [0, 0, 15])
|
41
|
+
linear_extrude(center = true, height = 0.500)
|
42
|
+
projection(cut = true)
|
43
|
+
translate(v = [0, 0, -15])
|
44
|
+
rotate(a = 30, v = [1, 1, 0])
|
45
|
+
difference() {
|
46
|
+
sphere(r = 25);
|
47
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
48
|
+
rotate(a = [90, 0])
|
49
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
50
|
+
rotate(a = [0, 90])
|
51
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
52
|
+
}
|
53
|
+
rotate(a = -30, v = [1, 1, 0])
|
54
|
+
translate(v = [0, 0, 10])
|
55
|
+
linear_extrude(center = true, height = 0.500)
|
56
|
+
projection(cut = true)
|
57
|
+
translate(v = [0, 0, -10])
|
58
|
+
rotate(a = 30, v = [1, 1, 0])
|
59
|
+
difference() {
|
60
|
+
sphere(r = 25);
|
61
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
62
|
+
rotate(a = [90, 0])
|
63
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
64
|
+
rotate(a = [0, 90])
|
65
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
66
|
+
}
|
67
|
+
rotate(a = -30, v = [1, 1, 0])
|
68
|
+
translate(v = [0, 0, 5])
|
69
|
+
linear_extrude(center = true, height = 0.500)
|
70
|
+
projection(cut = true)
|
71
|
+
translate(v = [0, 0, -5])
|
72
|
+
rotate(a = 30, v = [1, 1, 0])
|
73
|
+
difference() {
|
74
|
+
sphere(r = 25);
|
75
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
76
|
+
rotate(a = [90, 0])
|
77
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
78
|
+
rotate(a = [0, 90])
|
79
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
80
|
+
}
|
81
|
+
rotate(a = -30, v = [1, 1, 0])
|
82
|
+
translate(v = [0, 0, 0])
|
83
|
+
linear_extrude(center = true, height = 0.500)
|
84
|
+
projection(cut = true)
|
85
|
+
translate(v = [0, 0, 0])
|
86
|
+
rotate(a = 30, v = [1, 1, 0])
|
87
|
+
difference() {
|
88
|
+
sphere(r = 25);
|
89
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
90
|
+
rotate(a = [90, 0])
|
91
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
92
|
+
rotate(a = [0, 90])
|
93
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
94
|
+
}
|
95
|
+
rotate(a = -30, v = [1, 1, 0])
|
96
|
+
translate(v = [0, 0, -5])
|
97
|
+
linear_extrude(center = true, height = 0.500)
|
98
|
+
projection(cut = true)
|
99
|
+
translate(v = [0, 0, 5])
|
100
|
+
rotate(a = 30, v = [1, 1, 0])
|
101
|
+
difference() {
|
102
|
+
sphere(r = 25);
|
103
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
104
|
+
rotate(a = [90, 0])
|
105
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
106
|
+
rotate(a = [0, 90])
|
107
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
108
|
+
}
|
109
|
+
rotate(a = -30, v = [1, 1, 0])
|
110
|
+
translate(v = [0, 0, -10])
|
111
|
+
linear_extrude(center = true, height = 0.500)
|
112
|
+
projection(cut = true)
|
113
|
+
translate(v = [0, 0, 10])
|
114
|
+
rotate(a = 30, v = [1, 1, 0])
|
115
|
+
difference() {
|
116
|
+
sphere(r = 25);
|
117
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
118
|
+
rotate(a = [90, 0])
|
119
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
120
|
+
rotate(a = [0, 90])
|
121
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
122
|
+
}
|
123
|
+
rotate(a = -30, v = [1, 1, 0])
|
124
|
+
translate(v = [0, 0, -15])
|
125
|
+
linear_extrude(center = true, height = 0.500)
|
126
|
+
projection(cut = true)
|
127
|
+
translate(v = [0, 0, 15])
|
128
|
+
rotate(a = 30, v = [1, 1, 0])
|
129
|
+
difference() {
|
130
|
+
sphere(r = 25);
|
131
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
132
|
+
rotate(a = [90, 0])
|
133
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
134
|
+
rotate(a = [0, 90])
|
135
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
136
|
+
}
|
137
|
+
rotate(a = -30, v = [1, 1, 0])
|
138
|
+
translate(v = [0, 0, -20])
|
139
|
+
linear_extrude(center = true, height = 0.500)
|
140
|
+
projection(cut = true)
|
141
|
+
translate(v = [0, 0, 20])
|
142
|
+
rotate(a = 30, v = [1, 1, 0])
|
143
|
+
difference() {
|
144
|
+
sphere(r = 25);
|
145
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
146
|
+
rotate(a = [90, 0])
|
147
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
148
|
+
rotate(a = [0, 90])
|
149
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
150
|
+
}
|
151
|
+
%difference() {
|
152
|
+
sphere(r = 25);
|
153
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
154
|
+
rotate(a = [90, 0])
|
155
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
156
|
+
rotate(a = [0, 90])
|
157
|
+
cylinder(h = 62.500, r1 = 12.500, r2 = 6.250, center = true);
|
158
|
+
}
|
159
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "rubyscad"
|
2
|
+
require 'matrix'
|
3
|
+
|
4
|
+
module Example022
|
5
|
+
extend RubyScad
|
6
|
+
|
7
|
+
def self.roundedBox(size, radius, sidesonly)
|
8
|
+
rot = [ [0,0,0], [90,0,90], [90,90,0] ]
|
9
|
+
if (sidesonly)
|
10
|
+
cube(size: (size - Vector[2*radius,0,0]), center: true)
|
11
|
+
cube(size: (size - Vector[0,2*radius,0]), center: true)
|
12
|
+
[radius-size[0]/2, -radius+size[0]/2].each do |x|
|
13
|
+
[radius-size[1]/2, -radius+size[1]/2].each do |y|
|
14
|
+
translate(x: x, y: y); cylinder(r: radius, h: size[2], center: true)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
else
|
18
|
+
cube(size: [size[0], size[1]-radius*2, size[2]-radius*2], center: true)
|
19
|
+
cube(size: [size[0]-radius*2, size[1], size[2]-radius*2], center: true)
|
20
|
+
cube(size: [size[0]-radius*2, size[1]-radius*2, size[2]], center: true)
|
21
|
+
|
22
|
+
(0..2).each do |axis|
|
23
|
+
[radius-size[axis]/2, -radius+size[axis]/2].each do |x|
|
24
|
+
[radius-size[(axis+1)%3]/2, -radius+size[(axis+1)%3]/2].each do |y|
|
25
|
+
rotate(a: rot[axis])
|
26
|
+
translate(v: [x,y,0])
|
27
|
+
cylinder(h: size[(axis+2)%3]-2*radius, r: radius, center: true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
[radius-size[0]/2, -radius+size[0]/2].each do |x|
|
31
|
+
[radius-size[1]/2, -radius+size[1]/2].each do |y|
|
32
|
+
[radius-size[2]/2, -radius+size[2]/2].each do |z|
|
33
|
+
translate(v: [x,y,z]); sphere(r: radius)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
translate(v: [-15,0,0]) { roundedBox(Vector[20.0,30.0,40.0], 5.0, true) }
|
42
|
+
translate(v:[15,0,0]) { roundedBox(Vector[20.0,30.0,40.0], 5, false) }
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,103 @@
|
|
1
|
+
//created with rubyscad 1.0
|
2
|
+
|
3
|
+
translate(v = [-15, 0, 0]) {
|
4
|
+
cube(size = [10.000, 30.000, 40.000], center = true);
|
5
|
+
cube(size = [20.000, 20.000, 40.000], center = true);
|
6
|
+
translate(v = [-5.000, -10.000])
|
7
|
+
cylinder(r = 5.000, h = 40.000, center = true);
|
8
|
+
translate(v = [-5.000, 10.000])
|
9
|
+
cylinder(r = 5.000, h = 40.000, center = true);
|
10
|
+
translate(v = [5.000, -10.000])
|
11
|
+
cylinder(r = 5.000, h = 40.000, center = true);
|
12
|
+
translate(v = [5.000, 10.000])
|
13
|
+
cylinder(r = 5.000, h = 40.000, center = true);
|
14
|
+
}
|
15
|
+
translate(v = [15, 0, 0]) {
|
16
|
+
cube(size = [20.000, 20.000, 30.000], center = true);
|
17
|
+
cube(size = [10.000, 30.000, 30.000], center = true);
|
18
|
+
cube(size = [10.000, 20.000, 40.000], center = true);
|
19
|
+
rotate(a = [0, 0, 0])
|
20
|
+
translate(v = [-5.000, -10.000, 0])
|
21
|
+
cylinder(h = 30.000, r = 5, center = true);
|
22
|
+
rotate(a = [0, 0, 0])
|
23
|
+
translate(v = [-5.000, 10.000, 0])
|
24
|
+
cylinder(h = 30.000, r = 5, center = true);
|
25
|
+
rotate(a = [0, 0, 0])
|
26
|
+
translate(v = [5.000, -10.000, 0])
|
27
|
+
cylinder(h = 30.000, r = 5, center = true);
|
28
|
+
rotate(a = [0, 0, 0])
|
29
|
+
translate(v = [5.000, 10.000, 0])
|
30
|
+
cylinder(h = 30.000, r = 5, center = true);
|
31
|
+
translate(v = [-5.000, -10.000, -15.000])
|
32
|
+
sphere(r = 5);
|
33
|
+
translate(v = [-5.000, -10.000, 15.000])
|
34
|
+
sphere(r = 5);
|
35
|
+
translate(v = [-5.000, 10.000, -15.000])
|
36
|
+
sphere(r = 5);
|
37
|
+
translate(v = [-5.000, 10.000, 15.000])
|
38
|
+
sphere(r = 5);
|
39
|
+
translate(v = [5.000, -10.000, -15.000])
|
40
|
+
sphere(r = 5);
|
41
|
+
translate(v = [5.000, -10.000, 15.000])
|
42
|
+
sphere(r = 5);
|
43
|
+
translate(v = [5.000, 10.000, -15.000])
|
44
|
+
sphere(r = 5);
|
45
|
+
translate(v = [5.000, 10.000, 15.000])
|
46
|
+
sphere(r = 5);
|
47
|
+
rotate(a = [90, 0, 90])
|
48
|
+
translate(v = [-10.000, -15.000, 0])
|
49
|
+
cylinder(h = 10.000, r = 5, center = true);
|
50
|
+
rotate(a = [90, 0, 90])
|
51
|
+
translate(v = [-10.000, 15.000, 0])
|
52
|
+
cylinder(h = 10.000, r = 5, center = true);
|
53
|
+
rotate(a = [90, 0, 90])
|
54
|
+
translate(v = [10.000, -15.000, 0])
|
55
|
+
cylinder(h = 10.000, r = 5, center = true);
|
56
|
+
rotate(a = [90, 0, 90])
|
57
|
+
translate(v = [10.000, 15.000, 0])
|
58
|
+
cylinder(h = 10.000, r = 5, center = true);
|
59
|
+
translate(v = [-5.000, -10.000, -15.000])
|
60
|
+
sphere(r = 5);
|
61
|
+
translate(v = [-5.000, -10.000, 15.000])
|
62
|
+
sphere(r = 5);
|
63
|
+
translate(v = [-5.000, 10.000, -15.000])
|
64
|
+
sphere(r = 5);
|
65
|
+
translate(v = [-5.000, 10.000, 15.000])
|
66
|
+
sphere(r = 5);
|
67
|
+
translate(v = [5.000, -10.000, -15.000])
|
68
|
+
sphere(r = 5);
|
69
|
+
translate(v = [5.000, -10.000, 15.000])
|
70
|
+
sphere(r = 5);
|
71
|
+
translate(v = [5.000, 10.000, -15.000])
|
72
|
+
sphere(r = 5);
|
73
|
+
translate(v = [5.000, 10.000, 15.000])
|
74
|
+
sphere(r = 5);
|
75
|
+
rotate(a = [90, 90, 0])
|
76
|
+
translate(v = [-15.000, -5.000, 0])
|
77
|
+
cylinder(h = 20.000, r = 5, center = true);
|
78
|
+
rotate(a = [90, 90, 0])
|
79
|
+
translate(v = [-15.000, 5.000, 0])
|
80
|
+
cylinder(h = 20.000, r = 5, center = true);
|
81
|
+
rotate(a = [90, 90, 0])
|
82
|
+
translate(v = [15.000, -5.000, 0])
|
83
|
+
cylinder(h = 20.000, r = 5, center = true);
|
84
|
+
rotate(a = [90, 90, 0])
|
85
|
+
translate(v = [15.000, 5.000, 0])
|
86
|
+
cylinder(h = 20.000, r = 5, center = true);
|
87
|
+
translate(v = [-5.000, -10.000, -15.000])
|
88
|
+
sphere(r = 5);
|
89
|
+
translate(v = [-5.000, -10.000, 15.000])
|
90
|
+
sphere(r = 5);
|
91
|
+
translate(v = [-5.000, 10.000, -15.000])
|
92
|
+
sphere(r = 5);
|
93
|
+
translate(v = [-5.000, 10.000, 15.000])
|
94
|
+
sphere(r = 5);
|
95
|
+
translate(v = [5.000, -10.000, -15.000])
|
96
|
+
sphere(r = 5);
|
97
|
+
translate(v = [5.000, -10.000, 15.000])
|
98
|
+
sphere(r = 5);
|
99
|
+
translate(v = [5.000, 10.000, -15.000])
|
100
|
+
sphere(r = 5);
|
101
|
+
translate(v = [5.000, 10.000, 15.000])
|
102
|
+
sphere(r = 5);
|
103
|
+
}
|
File without changes
|
data/lib/rubyscad/version.rb
CHANGED
data/lib/rubyscad.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'rubyscad/version'
|
2
|
-
require 'RubyScad'
|
2
|
+
require 'rubyscad/RubyScad'
|
data/rubyscad.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require "rubyscad/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |gem|
|
8
|
+
gem.name = "rubyscad"
|
9
|
+
gem.version = RubyScad::VERSION
|
10
|
+
gem.authors = ["Curtis Bissonnette"]
|
11
|
+
gem.email = ["cjbissonnette@gmail.com"]
|
12
|
+
gem.homepage = "http://github.com/cjbissonnette/RubyScad"
|
13
|
+
gem.summary = %q{Easily use ruby to generate openscad scripts}
|
14
|
+
gem.description = %q{Use the full power of ruby to write openscad scripts.}
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
end
|