Class: MSPhysics::GearConnectionTool

Inherits:
Entity
  • Object
show all
Defined in:
RubyExtension/MSPhysics/gear_connection_tool.rb

Overview

Since:

  • 1.0.0

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#inspect, #to_s

Constructor Details

#initializeGearConnectionTool

Gears can be formed between Hinge, Motor, Servo, Slider, Piston, Spring, CurvySlider, and CurvyPiston joints. To connect gears

1. Select instance A.
2. Hold CTRL/SHIFT or both and select instance B.

To disconnect gears

1. Select a geared instance.
2. Hold SHIFT or CTRl+SHIFT and select the other instance.

To change reference joint.

1. Select a geared instance.
2. And click on one of the connected joints.

Changing name and gear ratio

1. Select a geared instance
2. Open MSPhysics UI
3. Navigate to gears section and edit properties.

Rules

1. Both instances must not be ignored and must be top-level entities.
2. Both instances must be connected to at least one joint.
3. Both instances can be connected to the same joint if the joint is
   either a Hinge, a Slider, a Spring, or a CurvySlider.
4. Both instances can be connected to multiple joints. By default,
   the first, connected joints are used for gears.

Copyable gears

* Copyable gears work in the same concept as copyable joints.

Specs

* Gear information is stored in one of the instances.
* When two instances are connected, both are assigned unique
  identifiers.
* Whenever simulation starts, all invalid gear attributes are removed.

Since:

  • 1.0.0



62
63
# File 'RubyExtension/MSPhysics/gear_connection_tool.rb', line 62

def initialize
end

Class Method Details

.activateBoolean

Activate joint connection tool.

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0



11
12
13
14
15
# File 'RubyExtension/MSPhysics/gear_connection_tool.rb', line 11

def activate
  return false if @@instance
  Sketchup.active_model.select_tool(self.new)
  true
end

.active?Boolean

Determine whether joint connection tool is active.

Returns:

  • (Boolean)

Since:

  • 1.0.0



27
28
29
# File 'RubyExtension/MSPhysics/gear_connection_tool.rb', line 27

def active?
  @@instance ? true : false
end

.deactivateBoolean

Deactivate joint connection tool.

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0



19
20
21
22
23
# File 'RubyExtension/MSPhysics/gear_connection_tool.rb', line 19

def deactivate
  return false unless @@instance
  Sketchup.active_model.select_tool(nil)
  true
end