Class: Bolt

Inherits:
BaseBoltPart show all
Defined in:
lib/rcad/nuts.rb

Instance Attribute Summary collapse

Attributes inherited from BaseBoltPart

#bolt_dia

Instance Method Summary collapse

Methods inherited from BaseBoltPart

#nut_dia_across_corners, #nut_dia_across_flats, #nut_height

Methods inherited from Shape

#*, #+, #-, #align, #back, #bbox, #bottom, #center, #cx, #cy, #cz, #extrude, #front, #left, #maxx, #maxy, #maxz, #minx, #miny, #minz, #mirror, #mirror_x, #mirror_y, #mirror_z, #move, #move_x, #move_y, #move_z, #revolve, #right, #rot_x, #rot_y, #rot_z, #rotate, #scale, #scale_x, #scale_y, #scale_z, #top, #transform, #xcenter, #xsize, #ycenter, #ysize, #zcenter, #zsize, #~@

Constructor Details

#initialize(bolt_dia, bolt_len, xytol = 0, ztol = 0) ⇒ Bolt

Returns a new instance of Bolt.



60
61
62
63
64
65
66
# File 'lib/rcad/nuts.rb', line 60

def initialize(bolt_dia, bolt_len, xytol=0, ztol=0)
  super(bolt_dia)

  @bolt_len = bolt_len
  @xytol = xytol
  @ztol = ztol
end

Instance Attribute Details

#bolt_lenObject

Returns the value of attribute bolt_len.



58
59
60
# File 'lib/rcad/nuts.rb', line 58

def bolt_len
  @bolt_len
end

#xytolObject

Returns the value of attribute xytol.



58
59
60
# File 'lib/rcad/nuts.rb', line 58

def xytol
  @xytol
end

#ztolObject

Returns the value of attribute ztol.



58
59
60
# File 'lib/rcad/nuts.rb', line 58

def ztol
  @ztol
end

Instance Method Details

#head_heightObject



68
69
70
# File 'lib/rcad/nuts.rb', line 68

def head_height
  0.7 * bolt_dia
end

#renderObject



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rcad/nuts.rb', line 76

def render
  d = nut_dia_across_corners + @xytol
  h = head_height + @ztol
  head = reg_prism(6, d / 2.0, h)

  add do
      ~head
      ~cylinder(total_len + @ztol, bolt_dia + @xytol)
        .move_z(-head_height)
    end
end

#total_lenObject



72
73
74
# File 'lib/rcad/nuts.rb', line 72

def total_len
  bolt_len + head_height
end