Class: HexNut

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, xytol = 0, ztol = 0, full = false) ⇒ HexNut

Returns a new instance of HexNut.



30
31
32
33
34
35
36
# File 'lib/rcad/nuts.rb', line 30

def initialize(bolt_dia, xytol=0, ztol=0, full=false)
  super(bolt_dia)

  @xytol = xytol
  @ztol = ztol
  @full = full
end

Instance Attribute Details

#fullObject

Returns the value of attribute full.



28
29
30
# File 'lib/rcad/nuts.rb', line 28

def full
  @full
end

#xytolObject

Returns the value of attribute xytol.



28
29
30
# File 'lib/rcad/nuts.rb', line 28

def xytol
  @xytol
end

#ztolObject

Returns the value of attribute ztol.



28
29
30
# File 'lib/rcad/nuts.rb', line 28

def ztol
  @ztol
end

Instance Method Details

#renderObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rcad/nuts.rb', line 38

def render
  d = nut_dia_across_corners + @xytol
  h = nut_height + @ztol

  nut = reg_prism(6, d / 2.0, h)
  
  if full
    return nut
  else
    return sub do
        ~nut
        ~cylinder(h + 0.02, bolt_dia + @xytol)
          .move_z(-0.01)
      end
  end
end