rubyscad 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -21
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +322 -322
- data/Rakefile +1 -1
- data/examples/BasicCube.rb +50 -50
- data/examples/ChamferCube.rb +96 -96
- data/examples/FilletCube.rb +317 -317
- data/examples/example001.rb +33 -33
- data/examples/example001.scad +11 -11
- data/examples/example002.rb +23 -23
- data/examples/example002.scad +18 -18
- data/examples/example003.rb +19 -19
- data/examples/example003.scad +15 -15
- data/examples/example004.rb +11 -11
- data/examples/example004.scad +6 -6
- data/examples/example005.rb +22 -22
- data/examples/example005.scad +31 -31
- data/examples/example006.rb +46 -46
- data/examples/example006.scad +221 -221
- data/examples/example007.dxf +2410 -2410
- data/examples/example007.rb +53 -53
- data/examples/example007.scad +30 -30
- data/examples/example008.dxf +3238 -3238
- data/examples/example008.rb +34 -34
- data/examples/example008.scad +26 -26
- data/examples/example009.dxf +3894 -3894
- data/examples/example009.rb +33 -33
- data/examples/example009.scad +15 -15
- data/examples/example010.dat +51 -51
- data/examples/example010.rb +12 -12
- data/examples/example010.scad +7 -7
- data/examples/example011.rb +22 -22
- data/examples/example011.scad +3 -3
- data/examples/example012.rb +16 -16
- data/examples/example012.scad +8 -8
- data/examples/example013.dxf +2276 -2276
- data/examples/example013.rb +16 -16
- data/examples/example013.scad +12 -12
- data/examples/example014.rb +14 -14
- data/examples/example014.scad +12 -12
- data/examples/example015.rb +33 -33
- data/examples/example015.scad +22 -22
- data/examples/example016.rb +43 -43
- data/examples/example016.scad +49 -49
- data/examples/example017.rb +170 -170
- data/examples/example017.scad +124 -124
- data/examples/example018.rb +29 -29
- data/examples/example018.scad +74 -74
- data/examples/example019.rb +22 -22
- data/examples/example019.scad +84 -84
- data/examples/example020.rb +92 -92
- data/examples/example020.scad +62 -62
- data/examples/example021.rb +42 -42
- data/examples/example021.scad +159 -159
- data/examples/example022.rb +44 -44
- data/examples/example022.scad +103 -103
- data/lib/rubyscad.rb +2 -2
- data/lib/rubyscad/RubyScad.rb +369 -361
- data/lib/rubyscad/version.rb +3 -3
- data/rubyscad.gemspec +20 -20
- metadata +7 -9
data/examples/example013.rb
CHANGED
@@ -1,16 +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
|
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
|
data/examples/example013.scad
CHANGED
@@ -1,12 +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
|
-
}
|
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
|
+
}
|
data/examples/example014.rb
CHANGED
@@ -1,14 +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
|
-
|
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
|
+
|
data/examples/example014.scad
CHANGED
@@ -1,12 +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
|
-
}
|
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
|
+
}
|
data/examples/example015.rb
CHANGED
@@ -1,33 +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
|
-
|
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
|
+
|
data/examples/example015.scad
CHANGED
@@ -1,22 +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);
|
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);
|
data/examples/example016.rb
CHANGED
@@ -1,43 +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
|
-
|
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
|
+
|
data/examples/example016.scad
CHANGED
@@ -1,49 +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
|
-
}
|
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
|
+
}
|
data/examples/example017.rb
CHANGED
@@ -1,170 +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()
|
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()
|