Class: JennCad::Extras::Din934
- Defined in:
- lib/jenncad/extras/din934.rb
Constant Summary collapse
- Data =
{2.5=> {side_to_side:5,height:2, support_diameter:2.8}, 3 => {side_to_side:5.5,height:2.4, support_diameter:3.5}, 4 => {side_to_side:7,height:3.2, support_diameter:4.4}, 5 => {side_to_side:8,height:4, support_diameter:5.3}, 6 => {side_to_side:10,height:5, support_diameter:6.3}, 8 => {side_to_side:13,height:6.5, support_diameter:8.3}, 10 => {side_to_side:17,height:8, support_diameter:10.3}, 12 => {side_to_side:19,height:10, support_diameter:12.3}, }
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#height ⇒ Object
Returns the value of attribute height.
Attributes inherited from Hardware
Instance Method Summary collapse
- #add_support(layer_height = @support_layer_height) ⇒ Object
- #cut ⇒ Object
-
#initialize(size, args = {}) ⇒ Din934
constructor
A new instance of Din934.
- #nut_934(show = true, margin = 0, height_margin = 0) ⇒ Object
- #show ⇒ Object
- #slot ⇒ Object
Methods inherited from Hardware
Constructor Details
#initialize(size, args = {}) ⇒ Din934
Returns a new instance of Din934.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jenncad/extras/din934.rb', line 16 def initialize(size,args={}) @size = size @options = args.dup @support = args[:support] ||= false @support_layer_height = args[:support_layer_height] ||= 0.2 @margin = args[:margin] ||= 0.2 # default output margin @slot = args[:slot] || nil @slot_margin = args[:slot_margin] || 0.2 @slot_direction = args[:slot_direction] || "z" @cylinder_length = args[:cylinder_length] || 0 # for slot only @transformations ||= [] @args = args @direction = args[:direction] || @slot_direction @s = Data[@size][:side_to_side] @height = Data[@size][:height] @support_diameter = Data[@size][:support_diameter] super(args) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/jenncad/extras/din934.rb', line 4 def data @data end |
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'lib/jenncad/extras/din934.rb', line 3 def height @height end |
Instance Method Details
#add_support(layer_height = @support_layer_height) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/jenncad/extras/din934.rb', line 39 def add_support(layer_height=@support_layer_height) res = cylinder(d:@support_diameter,h:@height-layer_height) # on very small nuts, add a support base of one layer height, so the support won't fall over if @size < 6 res += cylinder(d:@s-1,h:layer_height) end res end |
#cut ⇒ Object
75 76 77 |
# File 'lib/jenncad/extras/din934.rb', line 75 def cut Aggregation.new("din934c#{@size}#{option_string}", nut_934(false,@margin)) end |
#nut_934(show = true, margin = 0, height_margin = 0) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/jenncad/extras/din934.rb', line 83 def nut_934(show=true,margin=0,height_margin=0) size = @s + margin res = cylinder(d:(size/Math.sqrt(3))*2,h:@height+height_margin,fn:6) res -= cylinder(d:@size,h:@height) if show == true if @support res -= add_support end res.color("Gainsboro") if show res end |
#show ⇒ Object
79 80 81 |
# File 'lib/jenncad/extras/din934.rb', line 79 def show Aggregation.new("din934s#{@size}#{option_string}", nut_934) end |
#slot ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/jenncad/extras/din934.rb', line 48 def slot case @slot_direction when "x" pos = {x:@slot} when "y" pos = {y:@slot} when "z" pos = {z:@slot} when "-x" pos = {x:-@slot} when "-y" pos = {y:-@slot} when "-z" pos = {z:-@slot} else raise "Invalid slot direction #{@slot_direction}" end res = hull( nut_934(false,@margin,@slot_margin), nut_934(false,@margin,@slot_margin).move(pos) ) if @cylinder_length > 0 res += cylinder(d:@size+@margin,h:@cylinder_length) end res end |