Class: SolidRuby::Assemblies::Washer

Inherits:
Assembly show all
Defined in:
lib/solidruby/assemblies/washer.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

Methods inherited from Assembly

#*, #+, #-, #add_to_bom, #color, #colorize, get_skip, get_views, #output, #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, args = {}) ⇒ Washer

Returns a new instance of Washer.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/solidruby/assemblies/washer.rb', line 18

def initialize(size, args = {})
  @args = args
  @size = size
  @args[:type] ||= '125'
  @args[:material] ||= 'steel 8.8'
  @args[:surface] ||= 'zinc plated'

  @chart_din125 = {
    3.2 => { outer_diameter: 7, height: 0.5 },
    3.7 => { outer_diameter: 8, height: 0.5 },
    4.3 => { outer_diameter: 9, height: 0.8 },
    5.3 => { outer_diameter: 10, height: 1.0 },
    6.4 => { outer_diameter: 12, height: 1.6 },
    8.4 => { outer_diameter: 16, height: 1.6 },
    10.5 => { outer_diameter: 20, height: 2.0 },
    13.0 => { outer_diameter: 24, height: 2.5 }
  }
  if @chart_din125[@size].nil?
    @chart_din125.map { |k, _v| k }.sort.reverse.map { |s| s > @size ? size = s : nil }
    @size = size
  end
  @height = @chart_din125[@size][:height]

  @transformations ||= []
  super(args)
end

Instance Method Details

#descriptionObject



45
46
47
# File 'lib/solidruby/assemblies/washer.rb', line 45

def description
  "Washer #{@args[:size]}, Material #{@args[:material]} #{@args[:surface]}"
end

#showObject



49
50
51
52
53
54
55
# File 'lib/solidruby/assemblies/washer.rb', line 49

def show
  add_to_bom
  washer = cylinder(d: @chart_din125[@size][:outer_diameter].to_f, h: @chart_din125[@size][:height].to_f)
  washer -= cylinder(d: @size, h: @chart_din125[@size][:outer_diameter].to_f + 0.2).translate(z: -0.1)
  washer.color('Gainsboro')
  transform(washer)
end