Class: SolidRuby::Assemblies::Gear
- Inherits:
-
Assembly
- Object
- SolidRubyObject
- Assembly
- SolidRuby::Assemblies::Gear
- Defined in:
- lib/solidruby/assemblies/gear.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
this library is to be used to easily work with gears and their distances to each other.
-
#hub_dia ⇒ Object
readonly
this library is to be used to easily work with gears and their distances to each other.
-
#hub_height ⇒ Object
readonly
this library is to be used to easily work with gears and their distances to each other.
-
#module ⇒ Object
readonly
this library is to be used to easily work with gears and their distances to each other.
-
#teeth ⇒ Object
readonly
this library is to be used to easily work with gears and their distances to each other.
Attributes inherited from Assembly
#hardware, #skip, #transformations, #x, #y, #z
Attributes inherited from SolidRubyObject
#attributes, #children, #siblings, #transformations
Instance Method Summary collapse
- #distance_to(other_gear) ⇒ Object
-
#initialize(args = {}) ⇒ Gear
constructor
A new instance of Gear.
- #output ⇒ Object
- #ratio(other_gear) ⇒ Object
- #show ⇒ Object
Methods inherited from Assembly
#*, #+, #-, #add_to_bom, #color, #colorize, #description, 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(args = {}) ⇒ Gear
Returns a new instance of Gear.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/solidruby/assemblies/gear.rb', line 22 def initialize(args = {}) @module = args[:module] || 1.0 @teeth = args[:teeth] || 1.0 @bore = args[:bore] || 0.0 @height = args[:height] || 3.0 @hub_dia = args[:hub_dia] || 0.0 @hub_height = args[:hub_height] || 0.0 @output_margin_dia = args[:output_margin_dia] || 2 @output_margin_height = args[:output_margin_height] || 1 super(args) end |
Instance Attribute Details
#height ⇒ Object (readonly)
this library is to be used to easily work with gears and their distances to each other
20 21 22 |
# File 'lib/solidruby/assemblies/gear.rb', line 20 def height @height end |
#hub_dia ⇒ Object (readonly)
this library is to be used to easily work with gears and their distances to each other
20 21 22 |
# File 'lib/solidruby/assemblies/gear.rb', line 20 def hub_dia @hub_dia end |
#hub_height ⇒ Object (readonly)
this library is to be used to easily work with gears and their distances to each other
20 21 22 |
# File 'lib/solidruby/assemblies/gear.rb', line 20 def hub_height @hub_height end |
#module ⇒ Object (readonly)
this library is to be used to easily work with gears and their distances to each other
20 21 22 |
# File 'lib/solidruby/assemblies/gear.rb', line 20 def module @module end |
#teeth ⇒ Object (readonly)
this library is to be used to easily work with gears and their distances to each other
20 21 22 |
# File 'lib/solidruby/assemblies/gear.rb', line 20 def teeth @teeth end |
Instance Method Details
#distance_to(other_gear) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/solidruby/assemblies/gear.rb', line 56 def distance_to(other_gear) if @module != other_gear.module raise 'You cannot use two gears with different gear modules.' return end (@module.to_f * (@teeth.to_f + other_gear.teeth.to_f)) / 2.0 end |
#output ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/solidruby/assemblies/gear.rb', line 47 def output res = cylinder(d: @module * @teeth + @output_margin_dia, h: @height + @output_margin_height) if @hub_height.to_f > 0 && @hub_dia.to_f > 0 res += cylinder(d: @hub_dia + @output_margin_dia, h: @hub_height + @output_margin_height).translate(z: @height) end res end |
#ratio(other_gear) ⇒ Object
64 65 66 |
# File 'lib/solidruby/assemblies/gear.rb', line 64 def ratio(other_gear) @teeth.to_f / other_gear.teeth.to_f end |
#show ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/solidruby/assemblies/gear.rb', line 34 def show res = cylinder(d: @module * @teeth, h: @height) if @hub_height.to_f > 0 && @hub_dia.to_f > 0 res += cylinder(d: @hub_dia, h: @hub_height).translate(z: @height) end if @bore.to_f > 0.0 res -= cylinder(d: @bore, h: @height + @hub_height + 0.2).translate(z: -0.1) end res.color('darkgray') end |