solidruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +3 -0
- data/COPYING +674 -0
- data/Gemfile +2 -0
- data/Guardfile +24 -0
- data/LICENSE.md +675 -0
- data/README.md +180 -0
- data/Rakefile +10 -0
- data/bin/solidruby +61 -0
- data/examples/chamfered_cube.rb +39 -0
- data/examples/filleted_cube.rb +39 -0
- data/examples/gear.rb +11 -0
- data/examples/knurls.rb +12 -0
- data/examples/nut_support.rb +17 -0
- data/examples/openscad_examples/old/example001.rb +42 -0
- data/examples/openscad_examples/old/example002.rb +45 -0
- data/examples/openscad_examples/old/example003.rb +37 -0
- data/examples/openscad_examples/old/example004.rb +22 -0
- data/examples/openscad_examples/old/example005.rb +45 -0
- data/examples/openscad_examples/old/example006.rb +85 -0
- data/examples/openscad_examples/old/example007.dxf +2410 -0
- data/examples/openscad_examples/old/example007.rb +107 -0
- data/examples/openscad_examples/old/example008.rb +61 -0
- data/examples/openscad_examples/old/example009.dxf +3894 -0
- data/examples/openscad_examples/old/example009.rb.old +48 -0
- data/examples/openscad_examples/old/example010.dat +51 -0
- data/examples/openscad_examples/old/example010.rb +23 -0
- data/examples/openscad_examples/old/example011.rb +42 -0
- data/examples/openscad_examples/old/example012.rb +22 -0
- data/examples/openscad_examples/old/example012.stl +450 -0
- data/examples/openscad_examples/old/example013.dxf +2276 -0
- data/examples/openscad_examples/old/example013.rb +30 -0
- data/examples/openscad_examples/old/example014.rb +30 -0
- data/examples/openscad_examples/old/example015.rb +46 -0
- data/examples/openscad_examples/old/example016.rb +75 -0
- data/examples/openscad_examples/old/example016.stl +0 -0
- data/examples/pipe.rb +38 -0
- data/examples/pipe_bug.rb +16 -0
- data/examples/printed_gear.rb +12 -0
- data/examples/printed_gear2.rb +16 -0
- data/examples/printed_thread.rb +9 -0
- data/examples/printed_thread2.rb +13 -0
- data/examples/stack.rb +21 -0
- data/examples/threads.rb +183 -0
- data/examples/threads2.rb +93 -0
- data/examples/threads3.rb +46 -0
- data/lib/solidruby.rb +60 -0
- data/lib/solidruby/assemblies/assembly.rb +176 -0
- data/lib/solidruby/assemblies/bolt.rb +158 -0
- data/lib/solidruby/assemblies/gear.rb +131 -0
- data/lib/solidruby/assemblies/linear_bearing.rb +84 -0
- data/lib/solidruby/assemblies/nut.rb +153 -0
- data/lib/solidruby/assemblies/pipe.rb +153 -0
- data/lib/solidruby/assemblies/ruler.rb +44 -0
- data/lib/solidruby/assemblies/tslot.rb +141 -0
- data/lib/solidruby/assemblies/tslot_machining.rb +62 -0
- data/lib/solidruby/assemblies/washer.rb +57 -0
- data/lib/solidruby/bill_of_material.rb +43 -0
- data/lib/solidruby/csg_modelling/csg_modelling.rb +43 -0
- data/lib/solidruby/csg_modelling/difference.rb +41 -0
- data/lib/solidruby/csg_modelling/hull.rb +23 -0
- data/lib/solidruby/csg_modelling/intersection.rb +24 -0
- data/lib/solidruby/csg_modelling/minkowski.rb +23 -0
- data/lib/solidruby/csg_modelling/union.rb +41 -0
- data/lib/solidruby/csg_modifiers/color.rb +41 -0
- data/lib/solidruby/csg_modifiers/csg_modifier.rb +50 -0
- data/lib/solidruby/csg_modifiers/linear_extrude.rb +34 -0
- data/lib/solidruby/csg_modifiers/projection.rb +29 -0
- data/lib/solidruby/csg_modifiers/rotate_extrude.rb +30 -0
- data/lib/solidruby/extra.rb +58 -0
- data/lib/solidruby/helpers/chamfer.rb +27 -0
- data/lib/solidruby/helpers/fillet.rb +28 -0
- data/lib/solidruby/helpers/position.rb +267 -0
- data/lib/solidruby/helpers/rounded_cube.rb +37 -0
- data/lib/solidruby/helpers/triangle.rb +167 -0
- data/lib/solidruby/primitives/circle.rb +26 -0
- data/lib/solidruby/primitives/cube.rb +123 -0
- data/lib/solidruby/primitives/cylinder.rb +72 -0
- data/lib/solidruby/primitives/import.rb +42 -0
- data/lib/solidruby/primitives/polygon.rb +26 -0
- data/lib/solidruby/primitives/polyhedron.rb +30 -0
- data/lib/solidruby/primitives/primitive.rb +19 -0
- data/lib/solidruby/primitives/render.rb +48 -0
- data/lib/solidruby/primitives/sphere.rb +49 -0
- data/lib/solidruby/primitives/square.rb +88 -0
- data/lib/solidruby/primitives/surface.rb +44 -0
- data/lib/solidruby/primitives/text.rb +43 -0
- data/lib/solidruby/printed_thread.rb +163 -0
- data/lib/solidruby/rubyscad_bridge.rb +376 -0
- data/lib/solidruby/screw_thread.rb +170 -0
- data/lib/solidruby/solidruby.rb +150 -0
- data/lib/solidruby/solidruby_object.rb +176 -0
- data/lib/solidruby/transformations/mirror.rb +22 -0
- data/lib/solidruby/transformations/rotate.rb +22 -0
- data/lib/solidruby/transformations/scale.rb +22 -0
- data/lib/solidruby/transformations/transformation.rb +29 -0
- data/lib/solidruby/transformations/translate.rb +32 -0
- data/lib/solidruby/version.rb +18 -0
- data/lib/templates/assembly.tt +13 -0
- data/lib/templates/gitignore.tt +3 -0
- data/lib/templates/guardfile.tt +4 -0
- data/lib/templates/main.tt +20 -0
- data/lib/templates/params.tt +3 -0
- data/lib/templates/printed.tt +9 -0
- data/manual/manual.html +417 -0
- data/solidruby.gemspec +35 -0
- metadata +277 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
module SolidRuby::Assemblies
|
|
17
|
+
class Ruler < Assembly
|
|
18
|
+
def initialize(args = {})
|
|
19
|
+
@x = args[:x] || 50
|
|
20
|
+
@y = args[:y] || 5
|
|
21
|
+
@height = args[:height] || 1
|
|
22
|
+
@mm_mark = args[:mm_mark] || 3
|
|
23
|
+
@five_mm_mark = args[:five_mm_mark] || 4
|
|
24
|
+
@ten_mm_mark = args[:ten_mm_mark] || 5
|
|
25
|
+
@rotation = args[:rotation] || 0
|
|
26
|
+
|
|
27
|
+
super(args)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def part(_show)
|
|
31
|
+
res = cube([@x, @y, @height]).color('Gainsboro')
|
|
32
|
+
(@x + 1).times do |i|
|
|
33
|
+
res += cube([0.1, @mm_mark, @height + 0.1]).translate(x: i).color('black')
|
|
34
|
+
if i % 10 == 0
|
|
35
|
+
res += cube([0.1, @ten_mm_mark, @height + 0.1]).translate(x: i).color('black')
|
|
36
|
+
elsif i % 5 == 0
|
|
37
|
+
res += cube([0.1, @five_mm_mark, @height + 0.1]).translate(x: i).color('black')
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
res = res.rotate(z: @rotation) if @rotation > 0
|
|
41
|
+
res
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
#
|
|
16
|
+
module SolidRuby::Assemblies
|
|
17
|
+
class TSlot < Assembly
|
|
18
|
+
# the code in this class is based on code by edef1c
|
|
19
|
+
# Ported to SolidRuby by Jennifer Glauche
|
|
20
|
+
# License: GPLv3
|
|
21
|
+
attr_accessor :args
|
|
22
|
+
def initialize(args = {})
|
|
23
|
+
@args = args
|
|
24
|
+
|
|
25
|
+
@args[:size] ||= 20
|
|
26
|
+
@args[:length] ||= 100
|
|
27
|
+
@args[:configuration] ||= 1
|
|
28
|
+
@args[:gap] ||= 8.13
|
|
29
|
+
@args[:thickness] ||= 2.55
|
|
30
|
+
@args[:simple] ||= false
|
|
31
|
+
@machining = SolidRubyObject.new
|
|
32
|
+
@machining_string = ''
|
|
33
|
+
|
|
34
|
+
super(args)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def output
|
|
38
|
+
res = profile
|
|
39
|
+
res - @machining
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
alias show output
|
|
43
|
+
|
|
44
|
+
def description
|
|
45
|
+
"T-Slot #{@args[:size]}x#{@args[:size] * @args[:configuration]}, length #{@args[:length]}mm #{@machining_string}"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def length(length)
|
|
49
|
+
@args[:length] = length
|
|
50
|
+
self
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def thread(args = {})
|
|
54
|
+
position = args[:position] || 'front'
|
|
55
|
+
@machining_string += "with thread on #{position} "
|
|
56
|
+
self
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def threads
|
|
60
|
+
thread.thread(position: 'back')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def holes(args = {})
|
|
64
|
+
args[:position] = 'front'
|
|
65
|
+
res = hole(args)
|
|
66
|
+
args[:position] = 'back'
|
|
67
|
+
res.hole(args)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def hole(args = {})
|
|
71
|
+
diameter = args[:diameter] || 8
|
|
72
|
+
position = args[:position] || 'front'
|
|
73
|
+
side = args[:side] || 'x'
|
|
74
|
+
|
|
75
|
+
if position.is_a? String
|
|
76
|
+
case position
|
|
77
|
+
when 'front'
|
|
78
|
+
z = @args[:size] / 2
|
|
79
|
+
@machining_string += "with #{diameter}mm hole on front "
|
|
80
|
+
when 'back'
|
|
81
|
+
z = @args[:length] - @args[:size] / 2
|
|
82
|
+
@machining_string += "with #{diameter}mm hole on back "
|
|
83
|
+
end
|
|
84
|
+
else
|
|
85
|
+
z = position
|
|
86
|
+
@machining_string += "with #{diameter}mm hole on #{z}mm "
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
@args[:configuration].times do |c|
|
|
90
|
+
cyl = cylinder(d: diameter, h: @args[:size])
|
|
91
|
+
if side == 'x'
|
|
92
|
+
@machining += cyl.rotate(x: -90).translate(x: @args[:size] / 2 + c * @args[:size], z: z)
|
|
93
|
+
else
|
|
94
|
+
@machining += cyl.rotate(y: 90).translate(y: @args[:size] / 2 + c * @args[:size], z: z)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
self
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def profile
|
|
102
|
+
BillOfMaterial.bom.add(description) unless args[:no_bom] == true
|
|
103
|
+
return single_profile.color('Silver') if @args[:configuration] == 1
|
|
104
|
+
multi_profile.color('Silver')
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def single_profile
|
|
108
|
+
if @args[:simple] == true
|
|
109
|
+
cube([@args[:size], @args[:size], @args[:length]])
|
|
110
|
+
else
|
|
111
|
+
start = @args[:thickness].to_f / Math.sqrt(2)
|
|
112
|
+
|
|
113
|
+
gap = @args[:gap].to_f
|
|
114
|
+
thickness = @args[:thickness].to_f
|
|
115
|
+
size = @args[:size]
|
|
116
|
+
square_size = gap + thickness
|
|
117
|
+
if square_size > 0
|
|
118
|
+
profile = square(size: square_size, center: true)
|
|
119
|
+
else
|
|
120
|
+
profile = nil
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
(0..3).each do |d|
|
|
124
|
+
profile += polygon(points: [[0, 0], [0, start], [size / 2 - thickness - start, size / 2 - thickness], [gap / 2, size / 2 - thickness], [gap / 2, size / 2], [size / 2, size / 2], [size / 2, gap / 2], [size / 2 - thickness, gap / 2], [size / 2 - thickness, size / 2 - thickness - start], [start, 0]]).rotate(z: d * 90)
|
|
125
|
+
end
|
|
126
|
+
profile -= circle(r: gap / 2, center: true)
|
|
127
|
+
profile = profile.translate(x: size / 2, y: size / 2)
|
|
128
|
+
profile.linear_extrude(height: @args[:length], convexity: 2)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def multi_profile
|
|
133
|
+
res = single_profile
|
|
134
|
+
(@args[:configuration] - 1).times do |c|
|
|
135
|
+
c += 1
|
|
136
|
+
res += single_profile.translate(y: c * @args[:size])
|
|
137
|
+
end
|
|
138
|
+
res
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
#
|
|
16
|
+
module SolidRuby::Assemblies
|
|
17
|
+
class TSlotMachining < TSlot
|
|
18
|
+
def initialize(args = {})
|
|
19
|
+
super(args)
|
|
20
|
+
@args[:holes] ||= 'front,back' # nil, front, back
|
|
21
|
+
@args[:bolt_size] ||= 8
|
|
22
|
+
@args[:bolt_length] ||= 25
|
|
23
|
+
puts 'TSlotMachining is deprecated and will be removed in the 0.4.0 release.'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
alias tslot_output output
|
|
27
|
+
|
|
28
|
+
def output(length = nil)
|
|
29
|
+
tslot_output(length) - bolts
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def show(length = nil)
|
|
33
|
+
output(length) + bolts
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def bolts
|
|
37
|
+
bolt = SolidRubyObject.new
|
|
38
|
+
return bolt if @args[:holes].nil?
|
|
39
|
+
|
|
40
|
+
if @args[:holes].include?('front')
|
|
41
|
+
@args[:configuration].times do |c|
|
|
42
|
+
bolt += Bolt.new(@args[:bolt_size], @args[:bolt_length]).output.rotate(y: 90).translate(y: @args[:size] / 2 + c * @args[:size], z: @args[:size] / 2)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if @args[:holes].include?('back')
|
|
47
|
+
@args[:configuration].times do |c|
|
|
48
|
+
bolt += Bolt.new(@args[:bolt_size], @args[:bolt_length]).output.rotate(y: 90).translate(y: @args[:size] / 2 + c * @args[:size], z: @args[:length] - @args[:size] / 2)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
bolt
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def description
|
|
56
|
+
str = "T-Slot #{@args[:size]}x#{@args[:size] * @args[:configuration]}, length #{@args[:length]}mm"
|
|
57
|
+
if !@args[:holes].nil?
|
|
58
|
+
str << " with holes for M#{@args[:bolt_size]} on " + @args[:holes].split(',').join(' and ')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
#
|
|
16
|
+
module SolidRuby::Assemblies
|
|
17
|
+
class Washer < Assembly
|
|
18
|
+
def initialize(size, args = {})
|
|
19
|
+
@args = args
|
|
20
|
+
@size = size
|
|
21
|
+
@args[:type] ||= '125'
|
|
22
|
+
@args[:material] ||= 'steel 8.8'
|
|
23
|
+
@args[:surface] ||= 'zinc plated'
|
|
24
|
+
|
|
25
|
+
@chart_din125 = {
|
|
26
|
+
3.2 => { outer_diameter: 7, height: 0.5 },
|
|
27
|
+
3.7 => { outer_diameter: 8, height: 0.5 },
|
|
28
|
+
4.3 => { outer_diameter: 9, height: 0.8 },
|
|
29
|
+
5.3 => { outer_diameter: 10, height: 1.0 },
|
|
30
|
+
6.4 => { outer_diameter: 12, height: 1.6 },
|
|
31
|
+
8.4 => { outer_diameter: 16, height: 1.6 },
|
|
32
|
+
10.5 => { outer_diameter: 20, height: 2.0 },
|
|
33
|
+
13.0 => { outer_diameter: 24, height: 2.5 }
|
|
34
|
+
}
|
|
35
|
+
if @chart_din125[@size].nil?
|
|
36
|
+
@chart_din125.map { |k, _v| k }.sort.reverse.map { |s| s > @size ? size = s : nil }
|
|
37
|
+
@size = size
|
|
38
|
+
end
|
|
39
|
+
@height = @chart_din125[@size][:height]
|
|
40
|
+
|
|
41
|
+
@transformations ||= []
|
|
42
|
+
super(args)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def description
|
|
46
|
+
"Washer #{@args[:size]}, Material #{@args[:material]} #{@args[:surface]}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def show
|
|
50
|
+
add_to_bom
|
|
51
|
+
washer = cylinder(d: @chart_din125[@size][:outer_diameter].to_f, h: @chart_din125[@size][:height].to_f)
|
|
52
|
+
washer -= cylinder(d: @size, h: @chart_din125[@size][:outer_diameter].to_f + 0.2).translate(z: -0.1)
|
|
53
|
+
washer.color('Gainsboro')
|
|
54
|
+
transform(washer)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
module SolidRuby::BillOfMaterial
|
|
17
|
+
class BillOfMaterial
|
|
18
|
+
attr_accessor :parts
|
|
19
|
+
def initialize
|
|
20
|
+
@parts = {}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def add(part, quantity = 1)
|
|
24
|
+
@parts[part] ||= 0
|
|
25
|
+
@parts[part] += quantity
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def output
|
|
29
|
+
@parts.map { |key, qty| "#{qty} x #{key}" }.join("\n")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def save(filename = 'output/bom.txt')
|
|
33
|
+
file = File.open(filename, 'w')
|
|
34
|
+
file.puts output
|
|
35
|
+
file.close
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
@bom = BillOfMaterial.new
|
|
40
|
+
def self.bom
|
|
41
|
+
@bom
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
#
|
|
16
|
+
module SolidRuby::CSGModelling
|
|
17
|
+
class CSGModelling < SolidRuby::SolidRubyObject
|
|
18
|
+
def initialize(*list)
|
|
19
|
+
super(list)
|
|
20
|
+
@transformations = []
|
|
21
|
+
@children = list
|
|
22
|
+
@operation = self.class.name.split('::').last.downcase
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def to_rubyscad
|
|
26
|
+
@children ||= []
|
|
27
|
+
ret = "#{@operation}(){"
|
|
28
|
+
@children.each do |child|
|
|
29
|
+
begin
|
|
30
|
+
ret += child.walk_tree
|
|
31
|
+
rescue NoMethodError
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
# puts @children.map{|l| l.walk_tree_classes}.inspect
|
|
35
|
+
|
|
36
|
+
ret += '}'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_point_on(args = {})
|
|
40
|
+
@children[0].get_point_on(args) if @children.count > 0
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
#
|
|
16
|
+
module SolidRuby::CSGModelling
|
|
17
|
+
class Difference < CSGModelling
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def -(args)
|
|
21
|
+
return args if nil?
|
|
22
|
+
if args.is_a? Array
|
|
23
|
+
r = self
|
|
24
|
+
args.each do |a|
|
|
25
|
+
r = Difference.new(r, a)
|
|
26
|
+
end
|
|
27
|
+
r
|
|
28
|
+
else
|
|
29
|
+
optimize_difference(self, args)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def optimize_difference(top, child)
|
|
34
|
+
if top.is_a?(Difference) && (!child.is_a? Difference) && top.transformations.empty?
|
|
35
|
+
top.children << child
|
|
36
|
+
top
|
|
37
|
+
else
|
|
38
|
+
Difference.new(top, child)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
#
|
|
16
|
+
module SolidRuby::CSGModelling
|
|
17
|
+
class Hull < CSGModelling
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def hull(*parts)
|
|
21
|
+
Hull.new(*parts)
|
|
22
|
+
end
|
|
23
|
+
end
|