Class: SolidRuby::Assemblies::Bolt
- Inherits:
-
Assembly
- Object
- SolidRubyObject
- Assembly
- SolidRuby::Assemblies::Bolt
- Defined in:
- lib/solidruby/assemblies/bolt.rb
Instance Attribute Summary
Attributes inherited from Assembly
#hardware, #skip, #transformations, #x, #y, #z
Attributes inherited from SolidRubyObject
#attributes, #children, #siblings, #transformations
Instance Method Summary collapse
-
#bolt_7380(additional_length = 0, addtional_diameter = 0) ⇒ Object
ISO 7380.
-
#bolt_912(additional_length = 0, addtional_diameter = 0) ⇒ Object
DIN 912.
- #bolt_933(additional_length = 0, addtional_diameter = 0, head_margin = 0) ⇒ Object
- #description ⇒ Object
-
#initialize(size, length, args = {}) ⇒ Bolt
constructor
A new instance of Bolt.
- #output ⇒ Object
- #show ⇒ Object
Methods inherited from Assembly
#*, #+, #-, #add_to_bom, #color, #colorize, get_skip, get_views, #part, #scad_output, #show_hardware, skip, #threads, #transform, view, #walk_tree
Methods inherited from SolidRubyObject
#&, alias_attr, #debug, #debug?, #mirror, #place, #rotate, #rotate_around, #save, #scale, #to_rubyscad, #translate, #union, #walk_tree, #walk_tree_classes
Constructor Details
#initialize(size, length, args = {}) ⇒ Bolt
Returns a new instance of Bolt.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/solidruby/assemblies/bolt.rb', line 18 def initialize(size, length, args = {}) @args = args @args[:type] ||= '912' @args[:material] ||= 'steel 8.8' @args[:surface] ||= 'zinc plated' # options for output only: @args[:additional_length] ||= 0 @args[:additional_diameter] ||= 0.3 @args[:head_margin] ||= 0.0 if @args[:washer] == true @washer = Washer.new(size, material: @args[:material], surface: @args[:surface]) end @size = size @length = length @transformations ||= [] super(args) end |
Instance Method Details
#bolt_7380(additional_length = 0, addtional_diameter = 0) ⇒ Object
ISO 7380
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/solidruby/assemblies/bolt.rb', line 88 def bolt_7380(additional_length = 0, addtional_diameter = 0) chart_iso7380 = { 3 => { head_dia: 5.7, head_length: 1.65 }, 4 => { head_dia: 7.6, head_length: 2.2 }, 5 => { head_dia: 9.5, head_length: 2.75 }, 6 => { head_dia: 10.5, head_length: 3.3 }, 8 => { head_dia: 14, head_length: 4.4 }, 10 => { head_dia: 17.5, head_length: 5.5 }, 12 => { head_dia: 21, head_length: 6.6 } } res = cylinder(d1: chart_iso7380[@size][:head_dia] / 2.0, d2: chart_iso7380[@size][:head_dia], h: chart_iso7380[@size][:head_length]).translate(z: -chart_iso7380[@size][:head_length]).color('Gainsboro') total_length = @length + additional_length res += cylinder(d: @size + addtional_diameter, h: total_length).color('DarkGray') end |
#bolt_912(additional_length = 0, addtional_diameter = 0) ⇒ Object
DIN 912
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/solidruby/assemblies/bolt.rb', line 104 def bolt_912(additional_length = 0, addtional_diameter = 0) chart_din912 = { 2 => { head_dia: 3.8, head_length: 2, thread_length: 16 }, 2.5 => { head_dia: 4.5, head_length: 2.5, thread_length: 17 }, 3 => { head_dia: 5.5, head_length: 3, thread_length: 18 }, 4 => { head_dia: 7.0, head_length: 4, thread_length: 20 }, 5 => { head_dia: 8.5, head_length: 5, thread_length: 22 }, 6 => { head_dia: 10, head_length: 6, thread_length: 24 }, 8 => { head_dia: 13, head_length: 8, thread_length: 28 }, 10 => { head_dia: 16, head_length: 10, thread_length: 32 }, 12 => { head_dia: 18, head_length: 12, thread_length: 36 }, 14 => { head_dia: 21, head_length: 14, thread_length: 40 }, 16 => { head_dia: 24, head_length: 16, thread_length: 44 }, 18 => { head_dia: 27, head_length: 18, thread_length: 48 }, 20 => { head_dia: 30, head_length: 20, thread_length: 52 }, 22 => { head_dia: 33, head_length: 22, thread_length: 56 }, 24 => { head_dia: 36, head_length: 24, thread_length: 60 }, 30 => { head_dia: 45, head_length: 30, thread_length: 72 }, 36 => { head_dia: 54, head_length: 36, thread_length: 84 } } res = cylinder(d: chart_din912[@size][:head_dia], h: chart_din912[@size][:head_length]).translate(z: -chart_din912[@size][:head_length]).color('Gainsboro') total_length = @length + additional_length thread_length = chart_din912[@size][:thread_length] if total_length.to_f <= thread_length res += cylinder(d: @size + addtional_diameter, h: total_length).color('DarkGray') else res += cylinder(d: @size + addtional_diameter, h: total_length - thread_length).color('Gainsboro') res += cylinder(d: @size + addtional_diameter, h: thread_length).translate(z: total_length - thread_length).color('DarkGray') end res end |
#bolt_933(additional_length = 0, addtional_diameter = 0, head_margin = 0) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/solidruby/assemblies/bolt.rb', line 138 def bolt_933(additional_length = 0, addtional_diameter = 0, head_margin = 0) chart = { 2 => { head_side_to_side: 4, head_length: 1.4 }, 2.5 => { head_side_to_side: 5, head_length: 1.7 }, 3 => { head_side_to_side: 5.5, head_length: 2 }, 4 => { head_side_to_side: 7, head_length: 2.8 }, 5 => { head_side_to_side: 8, head_length: 3.5 }, 6 => { head_side_to_side: 10, head_length: 4 }, 8 => { head_side_to_side: 13, head_length: 5.5 }, 10 => { head_side_to_side: 17, head_length: 7 }, 12 => { head_side_to_side: 19, head_length: 8 }, 14 => { head_side_to_side: 22, head_length: 9 }, 16 => { head_side_to_side: 24, head_length: 10 } } head_dia = chart[@size][:head_side_to_side].to_f + head_margin.to_f res = cylinder(d: (head_dia / Math.sqrt(3)) * 2, fn: 6, h: chart[@size][:head_length]).translate(z: -chart[@size][:head_length]).color('Gainsboro') total_length = @length + additional_length res += cylinder(d: @size + addtional_diameter, h: total_length).color('DarkGray') end |
#description ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/solidruby/assemblies/bolt.rb', line 38 def description norm = '' if ['912', '933'].include? @args[:type] norm = 'DIN' elsif ['7380'].include? @args[:type] norm = 'ISO' end "M#{@size}x#{@length} Bolt, #{norm} #{@args[:type]}, #{@args[:material]} #{@args[:surface]}" end |
#output ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/solidruby/assemblies/bolt.rb', line 49 def output add_to_bom case @args[:type].to_s when '912' res = bolt_912(@args[:additional_length], @args[:additional_diameter]) when '933' res = bolt_933(@args[:additional_length], @args[:additional_diameter], @args[:head_margin]) when '7380' res = bolt_7380(@args[:additional_length], @args[:additional_diameter]) else raise "unkown type #{args[:type]} for Bolt!" end transform(res) end |
#show ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/solidruby/assemblies/bolt.rb', line 65 def show add_to_bom case @args[:type].to_s when '912' res = bolt_912(0, 0) when '933' res = bolt_933(0, 0) when '7380' res = bolt_7380(0, 0) else raise "unkown type #{args[:type]} for Bolt!" end @washer ||= nil if @washer res += @washer.show res = res.translate(z: -@washer.height) end transform(res) end |